index.vue 7.0 KB

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