index.vue 6.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306
  1. <template>
  2. <view>
  3. <view class='bargain-list'>
  4. <view class='header'>
  5. <img mode="widthFix" class="assistBg" src="../static/images/assist.png" alt="">
  6. </view>
  7. <view class='list'>
  8. <block v-for="(item,index) in assistList" :key="index">
  9. <view class='item acea-row row-between-wrapper' @tap="openSubscribe(item.product_assist_id)">
  10. <view class='pictrue'>
  11. <image :src='item.product.image'></image>
  12. </view>
  13. <view class='text acea-row row-column-around'>
  14. <view class='name line1'>{{item.store_name}}</view>
  15. <view class='num'><text class='iconfont icon-pintuan'></text>{{item.user_count}}人正在参与</view>
  16. <view class='money color-red'>助力价: ¥<text class='price'>{{item.assistSku ? item.assistSku[0].assist_price : ''}}</text></view>
  17. </view>
  18. <view class='cutBnt bg-color'></text>发起助力</view>
  19. </view>
  20. </block>
  21. </view>
  22. </view>
  23. <home></home>
  24. <!-- #ifdef MP -->
  25. <authorize @onLoadFun="onLoadFun" :isAuto="isAuto" :isShowAuth="isShowAuth" @authColse="authColse"></authorize>
  26. <!-- #endif -->
  27. </view>
  28. </template>
  29. <script>
  30. import {
  31. getAssistList,
  32. initiateAssistApi
  33. } from '../../../api/activity.js';
  34. import home from '@/components/home/index.vue';
  35. import {
  36. openBargainSubscribe
  37. } from '@/utils/SubscribeMessage.js';
  38. import {
  39. getUserInfo
  40. } from '@/api/user.js';
  41. import {
  42. toLogin
  43. } from '@/libs/login.js';
  44. import {
  45. mapGetters
  46. } from "vuex";
  47. // #ifdef MP
  48. import authorize from '@/components/Authorize';
  49. // #endif
  50. export default {
  51. components: {
  52. home,
  53. // #ifdef MP
  54. authorize
  55. // #endif
  56. },
  57. data() {
  58. return {
  59. topImage: '',
  60. assistList: [],
  61. active: 0,
  62. type: 0,
  63. scrollLeft: 0,
  64. interval: 0,
  65. status: 1,
  66. page: 1,
  67. limit: 8,
  68. loading: false,
  69. loadend: false,
  70. pageloading: false,
  71. userInfo: {},
  72. isAuto: false, //没有授权的不会自动授权
  73. isShowAuth: false, //是否隐藏授权
  74. }
  75. },
  76. /**
  77. * 用户点击右上角分享
  78. */
  79. // #ifdef MP
  80. onShareAppMessage: function() {
  81. wx.showShareMenu({
  82. withShareTicket: true,
  83. menus: ['shareAppMessage', 'shareTimeline']
  84. })
  85. return {
  86. title: '助力活动',
  87. path: 'pages/activity/assist/index',
  88. }
  89. },
  90. onShareTimeline: function() {
  91. return {
  92. title: '助力活动',
  93. query: {
  94. key: ''
  95. },
  96. imageUrl: ''
  97. }
  98. },
  99. // #endif
  100. computed: mapGetters(['isLogin']),
  101. watch:{
  102. isLogin:{
  103. handler:function(newV,oldV){
  104. if(newV){
  105. this.getUserInfo();
  106. this.getAssistProductList();
  107. }
  108. },
  109. deep:true
  110. }
  111. },
  112. onLoad() {
  113. this.getAssistProductList();
  114. if (this.isLogin) {
  115. this.getUserInfo();
  116. }
  117. },
  118. methods: {
  119. // 微信登录回调
  120. onLoadFun: function(e) {
  121. this.getUserInfo();
  122. this.isShowAuth = false
  123. },
  124. getAssistProductList: function() {
  125. var that = this;
  126. var data = {
  127. page: that.page,
  128. limit: that.limit,
  129. };
  130. if (that.loadend) return;
  131. if (that.pageloading) return;
  132. this.pageloading = true
  133. getAssistList(data).then(res => {
  134. console.log(res);
  135. var assistList = res.data.list;
  136. var loadend = assistList.length < that.limit;
  137. that.page++;
  138. that.assistList = that.assistList.concat(assistList),
  139. that.page = that.page;
  140. that.pageloading = false;
  141. that.loadend = loadend;
  142. }).catch(err => {
  143. that.pageloading = false
  144. });
  145. },
  146. openSubscribe: function(id) {
  147. if(this.isLogin){
  148. initiateAssistApi(id).then(res => {
  149. let id = res.data.product_assist_set_id;
  150. uni.hideLoading();
  151. // #ifndef MP
  152. uni.navigateTo({
  153. url: '/pages/activity/assist_detail/index?id='+id
  154. });
  155. // #endif
  156. // #ifdef MP
  157. openBargainSubscribe().then(res => {
  158. uni.hideLoading();
  159. uni.navigateTo({
  160. url: '/pages/activity/assist_detail/index?id='+id
  161. });
  162. }).catch((err) => {
  163. uni.showToast({
  164. title:err,
  165. icon:'none'
  166. })
  167. });
  168. // #endif
  169. }).catch((err) => {
  170. uni.showToast({
  171. title:err,
  172. icon:'none'
  173. })
  174. });
  175. }else{
  176. // #ifdef H5 || APP-PLUS
  177. toLogin();
  178. // #endif
  179. // #ifdef MP
  180. this.isAuto = true;
  181. this.$set(this, 'isShowAuth', true);
  182. // #endif
  183. }
  184. },
  185. // 授权关闭
  186. authColse: function(e) {
  187. this.isShowAuth = e
  188. },
  189. /*
  190. * 获取用户信息
  191. */
  192. getUserInfo: function() {
  193. let that = this;
  194. getUserInfo().then(res => {
  195. that.$set(that, 'userInfo', res.data);
  196. });
  197. },
  198. },
  199. /**
  200. * 页面上拉触底事件的处理函数
  201. */
  202. onReachBottom: function() {
  203. this.getAssistProductList();
  204. }
  205. }
  206. </script>
  207. <style lang="scss">
  208. page {
  209. background-color: #e93323;
  210. }
  211. .noCommodity{
  212. border-top: none;
  213. }
  214. .bargain-list .header {
  215. width: 100%;
  216. position: relative;
  217. }
  218. .bargain-list .header .assistBg {
  219. width: 750rpx;
  220. }
  221. .bargain-list .list {
  222. background-color: #fff;
  223. border: 6rpx solid #fc8b42;
  224. border-radius: 30rpx;
  225. margin: -90rpx 30rpx 66rpx 30rpx;
  226. padding: 0 24rpx;
  227. }
  228. .bargain-list .list .item {
  229. border-bottom: 1rpx solid #eee;
  230. position: relative;
  231. height: 223rpx;
  232. }
  233. .bargain-list .list .item .pictrue {
  234. width: 160rpx;
  235. height: 160rpx;
  236. }
  237. .bargain-list .list .item .pictrue image {
  238. width: 100%;
  239. height: 100%;
  240. border-radius: 6rpx;
  241. }
  242. .bargain-list .list .item .text {
  243. width: 450rpx;
  244. font-size: 30rpx;
  245. color: #282828;
  246. height: 160rpx;
  247. }
  248. .bargain-list .list .item .text .name {
  249. width: 100%;
  250. }
  251. .bargain-list .list .item .text .num {
  252. font-size: 26rpx;
  253. color: #999;
  254. }
  255. .bargain-list .list .item .text .num .iconfont {
  256. font-size: 35rpx;
  257. margin-right: 7rpx;
  258. }
  259. .bargain-list .list .item .text .money {
  260. font-size: 24rpx;
  261. font-weight: bold;
  262. }
  263. .color-red{
  264. color: #E93323;
  265. }
  266. .bargain-list .list .item .text .money .price {
  267. font-size: 32rpx;
  268. }
  269. .bargain-list .list .item .cutBnt {
  270. position: absolute;
  271. width: 180rpx;
  272. height: 50rpx;
  273. border-radius: 50rpx;
  274. font-size: 24rpx;
  275. color: #fff;
  276. text-align: center;
  277. line-height: 46rpx;
  278. right: 24rpx;
  279. bottom: 28rpx;
  280. box-shadow: 0 7rpx 0 #f8c1bd;
  281. }
  282. .bargain-list .list .item .cutBnt .iconfont {
  283. margin-right: 8rpx;
  284. font-size: 30rpx;
  285. }
  286. .bargain-list .list .load {
  287. font-size: 24rpx;
  288. height: 85rpx;
  289. text-align: center;
  290. line-height: 85rpx;
  291. }
  292. </style>