index.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323
  1. <template>
  2. <view :style="colorStyle" class="discount">
  3. <view class="header">
  4. <text v-if="type == 1">限时折扣</text>
  5. <text v-if="type == 4">满送活动</text>
  6. <text v-if="type == 3">满减满折</text>
  7. <text v-if="type == 2">第N件N折</text>
  8. </view>
  9. <view class="list">
  10. <view class="item acea-row row-between-wrapper" v-for="(item,index) in list" :key="index"
  11. @click="goDetails(item)">
  12. <view class="pictrue">
  13. <image :src="item.image"></image>
  14. </view>
  15. <view class="text">
  16. <view class="conter">
  17. <view class="name line2">{{item.store_name}}</view>
  18. <view class="info acea-row row-between" v-if="type == 4" @click.stop="giftGoods(item)">
  19. <view class="desc line2">{{item.promotions.desc}}</view>
  20. <view class="iconfont icon-you"></view>
  21. </view>
  22. </view>
  23. <view class="bnt acea-row row-between-wrapper" v-if="type != 4">
  24. <view class="left">
  25. <view class="title">
  26. <!-- <view class="iconfont icon-xianshi"></view> -->
  27. <view class="time" v-if="type == 1">限时:</view>
  28. <countDown v-if="type == 1" class="time mt" :tip-text="' '"
  29. :datatime="item.promotions.stop_time"></countDown>
  30. <view class="time" v-if="type == 2">{{item.promotions.title}}</view>
  31. <view class="time" v-if="type == 3">
  32. {{item.promotions.promotions.length==1?'最高':''}}
  33. {{item.promotions.promotions[0].discount_type==1?'可减'+item.promotions.promotions[0].discount:'可打'+parseFloat(item.promotions.promotions[0].discount)/10}}
  34. {{item.promotions.promotions[0].discount_type==1?'元':'折'}}
  35. </view>
  36. </view>
  37. <view class="money"><text class="label">¥</text><text class="num">{{item.price}}</text><text
  38. class="y_money">¥{{item.ot_price}}</text></view>
  39. </view>
  40. <view class="right acea-row row-center-wrapper">立即抢购</view>
  41. </view>
  42. <view class="bntCon acea-row row-between-wrapper" v-else>
  43. <view class="money">
  44. <text class="label">¥</text>
  45. <text class="num">{{item.price}}</text>
  46. <text class="y_money">{{item.ot_price}}</text>
  47. </view>
  48. <view class="right acea-row row-center-wrapper">立即抢购</view>
  49. </view>
  50. </view>
  51. </view>
  52. </view>
  53. <view class='loadingicon acea-row row-center-wrapper' v-if="list.length">
  54. <text class='loading iconfont icon-jiazai' :hidden='loading==false'></text>{{loadTitle}}
  55. </view>
  56. <giftGoods :giftInfo="giftInfo" @myevent="myGift"></giftGoods>
  57. <home v-if="navigation"></home>
  58. </view>
  59. </template>
  60. <script>
  61. import {
  62. mapGetters
  63. } from "vuex";
  64. import {
  65. promotionsList,
  66. giveInfo
  67. } from '@/api/activity.js';
  68. import home from '@/components/home';
  69. import colors from "@/mixins/color";
  70. import countDown from '@/components/countDown';
  71. import giftGoods from '../components/giftGoods/index.vue';
  72. export default {
  73. mixins: [colors],
  74. data() {
  75. return {
  76. list: [],
  77. loading: false,
  78. loadend: false,
  79. loadTitle: '加载更多', //提示语
  80. page: 1,
  81. limit: 10,
  82. type: 0,
  83. giftInfo:{
  84. show:false,
  85. giveCoupon:[],
  86. giveIntegral:[],
  87. giveProducts:[]
  88. }
  89. }
  90. },
  91. components: {
  92. countDown,
  93. giftGoods,
  94. home
  95. },
  96. onLoad(option) {
  97. this.type = option.promotions_type;
  98. this.getList();
  99. },
  100. onShow(){
  101. uni.removeStorageSync('form_type_cart');
  102. },
  103. onReachBottom: function() {
  104. this.getList();
  105. },
  106. methods: {
  107. giftGoods(item){
  108. this.giftInfo.show = true;
  109. giveInfo(item.promotions.id).then(res=>{
  110. this.giftInfo.giveCoupon = res.data.giveCoupon;
  111. this.giftInfo.giveProducts = res.data.giveProducts;
  112. let giveIntegral = res.data.giveIntegral;
  113. giveIntegral.forEach((item,index)=>{
  114. item.id = index;
  115. })
  116. this.giftInfo.giveIntegral = giveIntegral;
  117. }).catch(err=>{
  118. return this.$util.Tips({
  119. title: err
  120. });
  121. })
  122. },
  123. myGift(){
  124. this.$set(this.giftInfo, 'show', false);
  125. },
  126. goDetails(item) {
  127. uni.navigateTo({
  128. url: `/pages/goods_details/index?id=${item.id}&promotions_type=${this.type}`
  129. })
  130. },
  131. getList: function() {
  132. let that = this
  133. if (this.loadend) return false;
  134. if (this.loading) return false;
  135. that.loading = true;
  136. that.loadTitle = '加载更多';
  137. promotionsList(this.type, {
  138. page: that.page,
  139. limit: that.limit
  140. }).then(res => {
  141. let list = res.data.list,
  142. loadend = list.length < that.limit;
  143. let discountList = that.$util.SplitArray(list, that.list);
  144. that.$set(that, 'list', discountList);
  145. that.loadend = loadend;
  146. that.loading = false;
  147. that.loadTitle = loadend ? '没有更多内容啦~' : '加载更多';
  148. that.page = that.page + 1;
  149. }).catch(err => {
  150. that.loading = false;
  151. that.loadTitle = '加载更多';
  152. return that.$util.Tips({
  153. title: err
  154. });
  155. });
  156. },
  157. }
  158. }
  159. </script>
  160. <style scoped lang="scss">
  161. .mt {
  162. margin-top: 4rpx;
  163. }
  164. .discount {
  165. .header {
  166. width: 100%;
  167. height: 280rpx;
  168. background: url(../static/bg.png) no-repeat;
  169. background-size: 100% 100%;
  170. background-color: var(--view-theme);
  171. font-size: 56rpx;
  172. color: #fff;
  173. text-align: center;
  174. padding-top: 40rpx;
  175. }
  176. .list {
  177. margin-top: -118rpx;
  178. .item {
  179. width: 710rpx;
  180. height: 280rpx;
  181. background-color: #fff;
  182. border-radius: 16rpx;
  183. margin: 0 auto 18rpx auto;
  184. padding: 20rpx;
  185. .pictrue {
  186. width: 240rpx;
  187. height: 240rpx;
  188. border-radius: 16rpx;
  189. image {
  190. width: 100%;
  191. height: 100%;
  192. border-radius: 16rpx;
  193. }
  194. }
  195. .text {
  196. width: 416rpx;
  197. .conter {
  198. height: 150rpx;
  199. }
  200. .info {
  201. font-size: 20rpx;
  202. margin-top: 5rpx;
  203. color: var(--view-theme);
  204. .desc{
  205. width: 380rpx;
  206. }
  207. .iconfont{
  208. font-size: 18rpx;
  209. padding-top: 5rpx;
  210. }
  211. }
  212. .bntCon {
  213. width: 416rpx;
  214. height: 88rpx;
  215. .money {
  216. .label {
  217. font-size: 24rpx;
  218. font-weight: bold;
  219. color: var(--view-theme);
  220. }
  221. .y_money {
  222. color: #999999;
  223. font-size: 20rpx;
  224. text-decoration: line-through;
  225. margin-left: 6rpx;
  226. }
  227. .num {
  228. font-size: 32rpx;
  229. color: var(--view-theme);
  230. text-decoration: none;
  231. font-weight: bold;
  232. }
  233. }
  234. .right {
  235. width: 156rpx;
  236. height: 66rpx;
  237. border-radius: 34rpx;
  238. background: linear-gradient(135deg, var(--view-minorColor) 0%, var(--view-theme) 100%);
  239. font-size: 26rpx;
  240. color: #fff;
  241. }
  242. }
  243. .bnt {
  244. width: 416rpx;
  245. height: 88rpx;
  246. border-radius: 8rpx;
  247. background-color: var(--view-minorColorT);
  248. .left {
  249. padding-left: 12rpx;
  250. .time {
  251. display: inline-block;
  252. vertical-align: middle;
  253. }
  254. .title {
  255. font-size: 18rpx;
  256. color: var(--view-theme);
  257. .iconfont {
  258. font-size: 24rpx;
  259. margin-right: 8rpx;
  260. display: inline-block;
  261. vertical-align: bottom;
  262. }
  263. }
  264. .money {
  265. width: 261rpx;
  266. overflow: hidden;
  267. .label {
  268. font-size: 24rpx;
  269. font-weight: bold;
  270. color: var(--view-theme);
  271. }
  272. .y_money {
  273. color: #999999;
  274. font-size: 20rpx;
  275. text-decoration: line-through;
  276. margin-left: 6rpx;
  277. }
  278. .num {
  279. font-size: 32rpx;
  280. color: var(--view-theme);
  281. text-decoration: none;
  282. font-weight: bold;
  283. }
  284. }
  285. }
  286. .right {
  287. width: 134rpx;
  288. height: 100%;
  289. border-radius: 8rpx;
  290. background: linear-gradient(135deg, var(--view-minorColor) 0%, var(--view-theme) 100%);
  291. color: #fff;
  292. font-size: 26rpx;
  293. }
  294. }
  295. }
  296. }
  297. }
  298. }
  299. </style>