coupon-share.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290
  1. <template>
  2. <view class="container clearfix">
  3. <view class="container-list" v-if="isRequest">
  4. <view class="coupon-list">
  5. <view class="list-cell-le">
  6. <view class="list-cell-tags">
  7. <template v-if="coupon.moneyCouponFlag == 1">
  8. <text class="tags" v-if="coupon.moneyCouponType == 1"
  9. >意向{{ coupon.couponType | TypeFormat }}</text
  10. >
  11. <text class="tags" v-else>定向{{ coupon.couponType | TypeFormat }}</text>
  12. </template>
  13. <template v-else>
  14. <text class="tags">{{ coupon.couponType | TypeFormat }}</text>
  15. </template>
  16. </view>
  17. <view class="list-cell-price"> {{ coupon.couponAmount }}元满{{ coupon.touchPrice }}可用 </view>
  18. <view class="list-cell-texts">
  19. <text v-if="coupon.couponType == 0">
  20. {{ coupon.productType && coupon.productType == 1 ? '全商城商品通用' : '仅可购买指定商品' }}
  21. </text>
  22. <text v-if="coupon.couponType == 1">
  23. {{ coupon.categoryType == 1 ? '仅限购买产品类商品' : '仅限购买仪器类商品' }}
  24. </text>
  25. <text v-if="coupon.couponType == 3">仅限购买店铺【{{ coupon.shopName }}】的商品</text>
  26. <text v-if="coupon.couponType == 4 || coupon.couponType == 2">全商城商品通用</text>
  27. </view>
  28. <view class="list-cell-time">{{ coupon.startDate }} - {{ coupon.endDate }}</view>
  29. </view>
  30. <view class="list-cell-ri">
  31. <view class="coupon-minMoney">售价</view>
  32. <view class="coupon-maxMoney"> <text class="small">¥</text> {{ coupon.moneyCouponPrice }} </view>
  33. </view>
  34. </view>
  35. </view>
  36. <view class="container-button">
  37. <view class="button" @click="MiniWxPayFor">¥{{ coupon.moneyCouponPrice }}购买</view>
  38. </view>
  39. </view>
  40. </template>
  41. <script>
  42. import { mapState, mapMutations } from 'vuex'
  43. import authorize from '@/common/config/authorize.js'
  44. export default {
  45. data() {
  46. return {
  47. StaticUrl: this.$Static,
  48. isIphoneX: this.$store.state.isIphoneX,
  49. coupon: {},
  50. coupinList: [],
  51. userId: 0, // 机构Id
  52. couponId: 0, //优惠券Id
  53. payAmount: 100 ,//支付金额
  54. isRequest:false
  55. }
  56. },
  57. onLoad(option) {
  58. this.userId = option.userId
  59. this.couponId = option.couponId
  60. console.log('机构userId', this.userId)
  61. console.log('价值优惠券Id', this.couponId)
  62. this.initCouponDetail(this.couponId)
  63. },
  64. filters: {
  65. TypeFormat(value) {
  66. switch (value) {
  67. case 0:
  68. return '活动券'
  69. break
  70. case 1:
  71. return '品类券'
  72. break
  73. case 2:
  74. return '用户专享券'
  75. break
  76. case 3:
  77. return '店铺券'
  78. break
  79. case 4:
  80. return '新用户券'
  81. break
  82. }
  83. }
  84. },
  85. computed: {
  86. ...mapState(['hasLogin', 'userInfo', 'identity', 'isActivity'])
  87. },
  88. methods: {
  89. initCouponDetail(couponId) {
  90. // 初始化优惠券信息
  91. this.ProductService.QueryCouponDetail({ couponId: couponId })
  92. .then(response => {
  93. this.coupon = response.data
  94. this.isRequest = true
  95. })
  96. .catch(error => {
  97. console.log('初始化优惠券信息异常~')
  98. })
  99. },
  100. async MiniWxPayFor() {
  101. const wechatcode = await authorize.getCode('weixin')
  102. this.PayService.WeChatCouponMiniWxPay({
  103. userId: this.userId,
  104. couponId: this.couponId,
  105. payWay: 'WEIXIN',
  106. code: wechatcode
  107. })
  108. .then(response => {
  109. // 友盟埋点收集微信支付
  110. if (process.env.NODE_ENV != 'development') {
  111. this.$uma.trackEvent('Um_Event_ConfirmWechatPay', {
  112. Um_Key_PageName: '微信支付',
  113. Um_Key_SourcePage: '线上支付',
  114. Um_Key_PayName: `${this.buttonText}`,
  115. Um_Key_PayOrderID: `${this.orderId}`
  116. })
  117. }
  118. let PayInfo = JSON.parse(response.data.data.payInfo)
  119. this.WxRequestPayment(PayInfo)
  120. })
  121. .catch(error => {
  122. this.$util.msg(error.msg, 2000)
  123. })
  124. },
  125. WxRequestPayment(data) {
  126. let self = this
  127. wx.requestPayment({
  128. timeStamp: data.timeStamp,
  129. nonceStr: data.nonceStr,
  130. package: data.package,
  131. signType: data.signType,
  132. paySign: data.paySign,
  133. success: function(res) {
  134. wx.reLaunch({ url: '/pages/tabBar/user/user' })
  135. },
  136. fail: function(res) {
  137. self.$util.msg('用户取消支付~')
  138. },
  139. complete: function(res) {}
  140. })
  141. },
  142. navigator(url) {
  143. this.$api.navigateTo(url)
  144. }
  145. },
  146. onPullDownRefresh() {
  147. setTimeout(() => {
  148. this.QueryCouponList()
  149. uni.stopPullDownRefresh()
  150. }, 200)
  151. },
  152. onReachBottom() {
  153. if (this.hasNextPage) {
  154. this.loadding = true
  155. this.pullUpOn = true
  156. this.getOnReachBottomData()
  157. }
  158. },
  159. onShow() {}
  160. }
  161. </script>
  162. <style lang="scss">
  163. page {
  164. background-color: #f7f7f7;
  165. }
  166. .container {
  167. width: 100%;
  168. height: auto;
  169. }
  170. .container-list {
  171. box-sizing: border-box;
  172. padding: 24rpx;
  173. .empty-container-image {
  174. width: 260rpx;
  175. height: 260rpx;
  176. margin-top: -300rpx;
  177. }
  178. .toIndexPage {
  179. bottom: 390rpx;
  180. }
  181. .coupon-list {
  182. width: 702rpx;
  183. height: 202rpx;
  184. box-sizing: border-box;
  185. background: url(https://static.caimei365.com/app/img/icon/icon-coupon-buy@2x.png) no-repeat;
  186. background-position: center;
  187. background-size: auto 202rpx;
  188. position: relative;
  189. .list-cell-le {
  190. width: 502rpx;
  191. height: 100%;
  192. box-sizing: border-box;
  193. padding: 23rpx 32rpx;
  194. float: left;
  195. .list-cell-tags {
  196. width: 100%;
  197. height: 32rpx;
  198. margin-bottom: 7rpx;
  199. .tags {
  200. display: inline-block;
  201. padding: 0 10rpx;
  202. height: 32rpx;
  203. line-height: 32rpx;
  204. background: linear-gradient(270deg, #f94b4b 0%, #feb673 100%);
  205. color: #ffffff;
  206. font-size: $font-size-22;
  207. border-radius: 8rpx;
  208. text-align: center;
  209. float: left;
  210. }
  211. }
  212. .list-cell-price {
  213. width: 100%;
  214. height: 45rpx;
  215. line-height: 45rpx;
  216. font-size: $font-size-32;
  217. color: #333333;
  218. text-align: left;
  219. margin-top: 10rpx;
  220. font-weight: bold;
  221. }
  222. .list-cell-texts {
  223. width: 100%;
  224. height: auto;
  225. line-height: 40rpx;
  226. text-overflow: ellipsis;
  227. display: -webkit-box;
  228. word-break: break-all;
  229. -webkit-box-orient: vertical;
  230. -webkit-line-clamp: 1;
  231. overflow: hidden;
  232. font-size: 26rpx;
  233. color: #333333;
  234. }
  235. .list-cell-time {
  236. width: 100%;
  237. height: 32rpx;
  238. line-height: 32rpx;
  239. text-align: left;
  240. font-size: $font-size-20;
  241. color: #999999;
  242. }
  243. }
  244. .list-cell-ri {
  245. width: 200rpx;
  246. height: 100%;
  247. box-sizing: border-box;
  248. padding: 58rpx 0 0 0;
  249. float: right;
  250. .coupon-maxMoney {
  251. width: 100%;
  252. height: 78rpx;
  253. line-height: 78rpx;
  254. font-size: 40rpx;
  255. color: #f94b4b;
  256. text-align: center;
  257. .small {
  258. font-size: $font-size-26;
  259. }
  260. }
  261. .coupon-minMoney {
  262. width: 100%;
  263. height: 33rpx;
  264. line-height: 33rpx;
  265. font-size: $font-size-26;
  266. color: #f94b4b;
  267. text-align: center;
  268. }
  269. }
  270. }
  271. }
  272. .container-button {
  273. width: 100%;
  274. height: 90rpx;
  275. margin-top: 190rpx;
  276. .button {
  277. width: 600rpx;
  278. height: 90rpx;
  279. text-align: center;
  280. background: $btn-confirm;
  281. line-height: 90rpx;
  282. font-size: $font-size-30;
  283. color: #ffffff;
  284. margin: 0 auto;
  285. border-radius: 45rpx;
  286. }
  287. }
  288. </style>