coupon.vue 9.4 KB

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