金诚优选前端代码
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

210 lines
5.3 KiB

  1. <template>
  2. <view id="callList">
  3. <view class="no-list" v-if="!list.length && init">
  4. 暂无数据
  5. </view>
  6. <view class="call-item" v-for="(item, index) in list" :key="index" :data-goods="item.goods.id" :data-id="item.id" @tap="jumpCall" v-if="item.activity_status != 'End'">
  7. <view class="time mx-1px-bottom" v-if="item.activity_status == 'NoBegin'">
  8. <seckill :end="item.ends_at" typename="集call" :starts="item.starts_at" :index="index" :server="item.server_time" @starts="isStarts" @end="isEnd" mold="list"></seckill>
  9. </view>
  10. <view class="item-warp">
  11. <view class="call-img">
  12. <image :src="item.img"></image>
  13. </view>
  14. <view class="call-info">
  15. <view class="call-goods">
  16. <view class="goods-name">
  17. {{item.label}}
  18. </view>
  19. <view class="goods-money-box">
  20. <view class="money">
  21. <view class="new">
  22. {{item.goods.sell_price}}
  23. </view>
  24. <view class="old">
  25. {{item.goods.market_price}}
  26. </view>
  27. </view>
  28. <view class="nun">
  29. 限量{{item.limit}}
  30. </view>
  31. </view>
  32. </view>
  33. <view class="action-box">
  34. <view class="free">
  35. 集满{{item.per_count}}个Call即可免费领
  36. </view>
  37. <view class="action">
  38. 去打Call
  39. </view>
  40. </view>
  41. </view>
  42. </view>
  43. </view>
  44. </view>
  45. </template>
  46. <script>
  47. import {pageLogin, getUrl,config,is} from '@/common/js/utils.js';
  48. import Animation from '@/common/js/animation.js';
  49. import seckill from "@/components/seckill/seckill";
  50. export default {
  51. data() {
  52. return {
  53. init: false,
  54. list: []
  55. };
  56. },
  57. // 分享
  58. onShareAppMessage(res) {
  59. var title = config.BRAND.name == 'MIER' ? '米尔优选,惊喜不断,打 call 免费领火热进行中' : '惊喜不断,打 call 免费领火热进行中';
  60. return {
  61. title: title,
  62. path: '/pages/store/callList/callList'
  63. };
  64. },
  65. onLoad(e) {
  66. wx.showLoading({
  67. title: "加载中",
  68. mask: true
  69. });
  70. this.queryCallList();
  71. },
  72. components: {
  73. seckill
  74. },
  75. props: {},
  76. methods: {
  77. jump(e) {
  78. wx.navigateTo({
  79. url: '/pages/store/detail/detail?id=' + e.currentTarget.dataset.id
  80. });
  81. },
  82. jumpCall(e) {
  83. var token = this.$cookieStorage.get('user_token');
  84. if (token) {
  85. var id = e.currentTarget.dataset.id;
  86. wx.navigateTo({
  87. url: '/pages/store/call/call?id=' + id
  88. });
  89. } else {
  90. wx.showModal({
  91. content: '请先登录',
  92. success: res => {
  93. if (res.confirm || !res.cancel && !res.confirm) {
  94. pageLogin(getUrl());
  95. }
  96. }
  97. });
  98. }
  99. },
  100. // 请求打call列表
  101. queryCallList(page) {
  102. this.$http.get({
  103. api: 'api/free_event/list'
  104. }).then(res => {
  105. if (res.statusCode == 200) {
  106. res = res.data;
  107. if (res.status) {
  108. this.setData({
  109. list: res.data
  110. });
  111. } else {
  112. wx.showModal({
  113. title: '',
  114. content: '请求失败',
  115. showCancel: false
  116. });
  117. }
  118. } else {
  119. wx.showModal({
  120. content: '请求失败',
  121. showCancel: false
  122. });
  123. }
  124. wx.hideLoading();
  125. // this.setData({
  126. // show: false
  127. // });
  128. this.show=false;
  129. }).catch(err => {
  130. wx.hideLoading();
  131. this.show=false;
  132. });
  133. },
  134. // 集Call结束
  135. isEnd(e) {
  136. var index = e.detail.index;
  137. if (index != undefined) {
  138. var item = this.list[index];
  139. if (item.activity_status != 'End') {
  140. // this.setData({
  141. // [`list[${index}].activity_status`]: 'End'
  142. // });
  143. this.list[index].activity_status='End';
  144. }
  145. }
  146. },
  147. // 集call开始
  148. isStarts(e) {
  149. var index = e.detail.index;
  150. if (index != undefined) {
  151. var item = this.list[index];
  152. if (item.activity_status != 'End') {
  153. // this.setData({
  154. // [`list[${index}].activity_status`]: 'OnGoing'
  155. // });
  156. this.list[index].activity_status='OnGoing';
  157. }
  158. }
  159. },
  160. setData: function (obj) {
  161. let that = this;
  162. let keys = [];
  163. let val, data;
  164. Object.keys(obj).forEach(function (key) {
  165. keys = key.split('.');
  166. val = obj[key];
  167. data = that.$data;
  168. keys.forEach(function (key2, index) {
  169. if (index + 1 == keys.length) {
  170. that.$set(data, key2, val);
  171. } else {
  172. if (!data[key2]) {
  173. that.$set(data, key2, {});
  174. }
  175. }
  176. data = data[key2];
  177. });
  178. });
  179. }
  180. },
  181. computed: {},
  182. watch: {}
  183. };
  184. </script>
  185. <style rel="stylesheet/less" lang="less">
  186. @import "callList";
  187. </style>