coupon.vue 9.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377
  1. <template>
  2. <view class="container clearfix">
  3. <view class="container-list" v-show="isRequest">
  4. <view class="empty-container" v-if="showEmpty">
  5. <image class="empty-container-image" :src="StaticUrl + '/icon/icon-coupon-empty@2x.png'"></image>
  6. <text class="error-text">暂无优惠券~</text>
  7. </view>
  8. <template v-else>
  9. <view v-for="(coupon, index) in coupinList" :key="index" :id="coupon.id" class="coupon-list">
  10. <view class="list-cell-tag" v-if="coupon.couponPayWay == 1">售价¥{{ coupon.moneyCouponPrice }}</view>
  11. <view class="list-cell-tag" v-else>售价{{ coupon.moneyCouponPrice }}采美豆</view>
  12. <view class="list-cell-le">
  13. <view class="coupon-maxMoney"> <text class="small">¥</text> {{ coupon.couponAmount }} </view>
  14. <view class="coupon-minMoney"> 满{{ coupon.touchPrice }}可用 </view>
  15. </view>
  16. <view class="list-cell-ri">
  17. <view class="list-cell-top">
  18. <view class="list-cell-type">
  19. <view class="list-cell-tags">
  20. <template v-if="coupon.moneyCouponFlag == 1">
  21. <text class="tags" v-if="coupon.moneyCouponType == 1"
  22. >意向{{ coupon.couponType | TypeFormat }}</text
  23. >
  24. <text class="tags" v-else>定向{{ coupon.couponType | TypeFormat }}</text>
  25. </template>
  26. <template v-else>
  27. <text class="tags">{{ coupon.couponType | TypeFormat }}</text>
  28. </template>
  29. </view>
  30. <view class="list-cell-texts">
  31. <text v-if="coupon.couponType == 0">
  32. {{
  33. coupon.productType && coupon.productType == 1
  34. ? '全商城商品通用'
  35. : '仅可购买指定商品'
  36. }}
  37. </text>
  38. <text v-if="coupon.couponType == 1">
  39. {{ coupon.categoryType == 1 ? '仅限购买产品类商品' : '仅限购买仪器类商品' }}
  40. </text>
  41. <text v-if="coupon.couponType == 3"
  42. >仅限购买店铺【{{ coupon.shopName }}】的商品</text
  43. >
  44. <text v-if="coupon.couponType == 4 || coupon.couponType == 2">全商城商品通用</text>
  45. </view>
  46. </view>
  47. <view class="list-cell-btn">
  48. <view class="icon-used">
  49. <button open-type="share" class="icon-used-btn receive" :data-coupon="coupon">
  50. 分享购买
  51. </button>
  52. </view>
  53. </view>
  54. </view>
  55. <view class="list-cell-time">{{ coupon.startDate }} - {{ coupon.endDate }}</view>
  56. </view>
  57. </view>
  58. <!--加载loadding-->
  59. <tui-loadmore :visible="loadding" :index="3" type="black"></tui-loadmore>
  60. <tui-nomore :visible="!pullUpOn" :backgroundColor="'#F7F7F7'" :text="nomoreText"></tui-nomore>
  61. <!--加载loadding-->
  62. </template>
  63. </view>
  64. </view>
  65. </template>
  66. <script>
  67. import { mapState, mapMutations } from 'vuex'
  68. import couponTabs from '@/components/cm-module/coupon/tui-tabs.vue'
  69. export default {
  70. components: {
  71. couponTabs
  72. },
  73. data() {
  74. return {
  75. StaticUrl: this.$Static,
  76. isIphoneX: this.$store.state.isIphoneX,
  77. listQuery: {
  78. userId:0,
  79. pageNum: 1,
  80. pageSize: 10
  81. },
  82. coupinList: [],
  83. isRequest: false,
  84. showEmpty: false,
  85. nomoreText: '上拉显示更多',
  86. hasNextPage: false,
  87. loadding: false,
  88. pullUpOn: true,
  89. pullFlag: true,
  90. isReceiveLoading: false, //领券操作状态
  91. }
  92. },
  93. onLoad() {
  94. uni.hideShareMenu()
  95. this.initGetStotage()
  96. },
  97. filters: {
  98. TypeFormat(value) {
  99. switch (value) {
  100. case 0:
  101. return '活动券'
  102. break
  103. case 1:
  104. return '品类券'
  105. break
  106. case 2:
  107. return '用户专享券'
  108. break
  109. case 3:
  110. return '店铺券'
  111. break
  112. case 4:
  113. return '新用户券'
  114. break
  115. }
  116. }
  117. },
  118. computed: {
  119. ...mapState(['hasLogin', 'userInfo', 'identity', 'isActivity'])
  120. },
  121. methods: {
  122. async initGetStotage() {
  123. const userInfo = await this.$api.getStorage()
  124. const clubInfo = await this.$api.getComStorage('orderUserInfo')
  125. this.listQuery.userId = clubInfo.userId ? clubInfo.userId : 0
  126. this.QueryCouponList()
  127. },
  128. QueryCouponList() {
  129. // 初始化查询优惠券列表
  130. this.coupinList = []
  131. this.listQuery.pageNum = 1
  132. this.ProductService.QueryMoneyCouponList(this.listQuery)
  133. .then(response => {
  134. let data = response.data
  135. if (data.list && data.list.length > 0) {
  136. this.showEmpty = false
  137. this.hasNextPage = response.data.hasNextPage
  138. this.coupinList = data.list
  139. this.pullFlag = false
  140. setTimeout(() => {
  141. this.pullFlag = true
  142. }, 500)
  143. if (this.hasNextPage) {
  144. this.pullUpOn = false
  145. this.nomoreText = '上拉显示更多'
  146. } else {
  147. if (this.coupinList.length < 8) {
  148. this.pullUpOn = true
  149. } else {
  150. this.pullUpOn = false
  151. this.loadding = false
  152. this.nomoreText = '已至底部'
  153. }
  154. }
  155. } else {
  156. this.showEmpty = true
  157. }
  158. this.isRequest = true
  159. })
  160. .catch(error => {
  161. this.$util.msg(error.msg, 2000)
  162. })
  163. },
  164. getOnReachBottomData() {
  165. // 上滑加载分页
  166. this.listQuery.pageNum += 1
  167. this.ProductService.QueryCouponCollarList(this.listQuery)
  168. .then(response => {
  169. let data = response.data
  170. if (data.list && data.list.length > 0) {
  171. this.hasNextPage = data.hasNextPage
  172. this.coupinList = this.coupinList.concat(data.list)
  173. this.pullFlag = false // 防上拉暴滑
  174. setTimeout(() => {
  175. this.pullFlag = true
  176. }, 500)
  177. if (this.hasNextPage) {
  178. this.pullUpOn = false
  179. this.nomoreText = '上拉显示更多'
  180. } else {
  181. this.pullUpOn = false
  182. this.loadding = false
  183. this.nomoreText = '已至底部'
  184. }
  185. }
  186. })
  187. .catch(error => {
  188. this.$util.msg(error.msg, 2000)
  189. })
  190. },
  191. navigator(url) {
  192. this.$api.navigateTo(url)
  193. }
  194. },
  195. onShareAppMessage(res) {
  196. //分享购买优惠券
  197. const coupon = res.target.dataset.coupon
  198. console.log('优惠券', coupon)
  199. console.log('机构Id', this.listQuery.userId)
  200. if (res.from === 'button') {
  201. // console.log('来自页面内转发按钮')
  202. return {
  203. title: `只售${coupon.moneyCouponPrice}元,${coupon.couponAmount}元优惠券等您抢购~`,
  204. path: `pages/seller/cart/coupon-share?couponId=${coupon.couponId}&userId=${this.listQuery.userId}`,
  205. imageUrl: 'https://static.caimei365.com/app/img/icon/icon-shareCoupon@2x.png'
  206. }
  207. }
  208. },
  209. onPullDownRefresh() {
  210. setTimeout(() => {
  211. this.QueryCouponList()
  212. uni.stopPullDownRefresh()
  213. }, 200)
  214. },
  215. onReachBottom() {
  216. if (this.hasNextPage) {
  217. this.loadding = true
  218. this.pullUpOn = true
  219. this.getOnReachBottomData()
  220. }
  221. },
  222. onShow() {}
  223. }
  224. </script>
  225. <style lang="scss">
  226. page {
  227. background-color: #f7f7f7;
  228. }
  229. .container {
  230. width: 100%;
  231. height: auto;
  232. }
  233. .container-list {
  234. box-sizing: border-box;
  235. padding: 24rpx;
  236. .empty-container-image {
  237. width: 260rpx;
  238. height: 260rpx;
  239. margin-top: -300rpx;
  240. }
  241. .toIndexPage {
  242. bottom: 390rpx;
  243. }
  244. .coupon-list {
  245. width: 100%;
  246. height: 200rpx;
  247. margin-bottom: 24rpx;
  248. box-sizing: border-box;
  249. background: url(https://static.caimei365.com/app/img/icon/icon-coupon-uesb@2x.png);
  250. background-size: cover;
  251. position: relative;
  252. .list-cell-tag {
  253. height: 32rpx;
  254. line-height: 32rpx;
  255. text-align: center;
  256. padding: 0 10rpx;
  257. background-color: #fee756;
  258. color: #f94b4b;
  259. font-size: $font-size-20;
  260. position: absolute;
  261. top: 0;
  262. border-radius: 8rpx 0 8rpx 0;
  263. }
  264. .list-cell-le {
  265. width: 224rpx;
  266. height: 100%;
  267. box-sizing: border-box;
  268. padding: 37rpx 0;
  269. float: left;
  270. .coupon-maxMoney {
  271. width: 100%;
  272. height: 78rpx;
  273. line-height: 78rpx;
  274. font-size: 56rpx;
  275. color: #ffffff;
  276. text-align: center;
  277. .small {
  278. font-size: $font-size-24;
  279. }
  280. }
  281. .coupon-minMoney {
  282. width: 100%;
  283. height: 33rpx;
  284. line-height: 33rpx;
  285. font-size: $font-size-24;
  286. color: #ffffff;
  287. text-align: center;
  288. }
  289. }
  290. .list-cell-ri {
  291. width: 478rpx;
  292. height: 100%;
  293. box-sizing: border-box;
  294. padding: 20rpx 24rpx 0 24rpx;
  295. float: right;
  296. .list-cell-top {
  297. width: 100%;
  298. height: 121rpx;
  299. float: left;
  300. border-bottom: 1px solid #e1e1e1;
  301. .list-cell-type {
  302. width: 286rpx;
  303. height: 100%;
  304. float: left;
  305. .list-cell-tags {
  306. width: 100%;
  307. height: 32rpx;
  308. margin-bottom: 7rpx;
  309. .tags {
  310. display: inline-block;
  311. padding: 0 10rpx;
  312. height: 32rpx;
  313. line-height: 32rpx;
  314. background-color: #ffdcce;
  315. color: #f94b4b;
  316. font-size: $font-size-20;
  317. border-radius: 8rpx;
  318. text-align: center;
  319. float: left;
  320. }
  321. }
  322. .list-cell-texts {
  323. width: 100%;
  324. height: auto;
  325. line-height: 35rpx;
  326. text-overflow: ellipsis;
  327. display: -webkit-box;
  328. word-break: break-all;
  329. -webkit-box-orient: vertical;
  330. -webkit-line-clamp: 2;
  331. overflow: hidden;
  332. font-size: 26rpx;
  333. color: #333333;
  334. }
  335. }
  336. .list-cell-btn {
  337. width: 128rpx;
  338. height: 100%;
  339. float: right;
  340. .icon-used {
  341. width: 100%;
  342. height: 100%;
  343. box-sizing: border-box;
  344. padding-top: 57rpx;
  345. .icon-used-btn {
  346. width: 128rpx;
  347. height: 48rpx;
  348. border-radius: 28rpx;
  349. line-height: 48rpx;
  350. font-size: $font-size-26;
  351. text-align: center;
  352. &.receive {
  353. background-image: linear-gradient(270deg, #f94b4b 0%, #feb673 100%);
  354. color: #ffffff;
  355. }
  356. &.make {
  357. border: solid 1px #f94b4b;
  358. color: #f94b4b;
  359. }
  360. }
  361. }
  362. }
  363. }
  364. .list-cell-time {
  365. width: 100%;
  366. height: 58rpx;
  367. line-height: 58rpx;
  368. text-align: left;
  369. font-size: $font-size-20;
  370. color: #999999;
  371. }
  372. }
  373. }
  374. }
  375. </style>