coupon-share.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313
  1. <template>
  2. <view class="container clearfix" >
  3. <tui-skeleton v-if="skeletonShow" backgroundColor="#fafafa" borderRadius="10rpx" :isLoading ="true" :loadingType="5"></tui-skeleton>
  4. <view class="container-content tui-skeleton" v-else>
  5. <view class="container-list">
  6. <view class="coupon-list">
  7. <view class="list-cell-le">
  8. <view class="list-cell-tags">
  9. <template v-if="coupon.moneyCouponFlag == 1">
  10. <text class="tags" v-if="coupon.moneyCouponType == 1"
  11. >意向{{ coupon.couponType | TypeFormat }}</text
  12. >
  13. <text class="tags" v-else>定向{{ coupon.couponType | TypeFormat }}</text>
  14. </template>
  15. <template v-else>
  16. <text class="tags">{{ coupon.couponType | TypeFormat }}</text>
  17. </template>
  18. </view>
  19. <view class="list-cell-price"> {{ coupon.couponAmount }}元满{{ coupon.touchPrice }}可用 </view>
  20. <view class="list-cell-texts">
  21. <text v-if="coupon.couponType == 0">
  22. {{ coupon.productType && coupon.productType == 1 ? '全商城商品通用' : '仅可购买指定商品' }}
  23. </text>
  24. <text v-if="coupon.couponType == 1">
  25. {{ coupon.categoryType == 1 ? '仅限购买产品类商品' : '仅限购买仪器类商品' }}
  26. </text>
  27. <text v-if="coupon.couponType == 3">仅限购买店铺【{{ coupon.shopName }}】的商品</text>
  28. <text v-if="coupon.couponType == 4 || coupon.couponType == 2">全商城商品通用</text>
  29. </view>
  30. <view class="list-cell-time">{{ coupon.startDate }} - {{ coupon.endDate }}</view>
  31. </view>
  32. <view class="list-cell-ri">
  33. <view class="coupon-minMoney">售价</view>
  34. <view class="coupon-maxMoney"> <text class="small">¥</text> {{ coupon.moneyCouponPrice }} </view>
  35. </view>
  36. </view>
  37. </view>
  38. <view class="container-button">
  39. <view class="button" @click="createCouponRecord">¥{{ coupon.moneyCouponPrice }}购买</view>
  40. </view>
  41. </view>
  42. <!-- 弹窗提示 -->
  43. <tui-modal
  44. :show="modal"
  45. @click="handleClick"
  46. @cancel="hideMobel"
  47. :content="contentModalText"
  48. :button="modalButton"
  49. color="#333"
  50. :size="32"
  51. shape="circle"
  52. :maskClosable="false"
  53. >
  54. </tui-modal>
  55. </view>
  56. </template>
  57. <script>
  58. import { mapState, mapMutations } from 'vuex'
  59. import wxLogin from '@/common/config/wxLogin.js'
  60. import authorize from '@/common/config/authorize.js'
  61. import wechatPay from '@/utils/mixins/wechatPay.js'
  62. export default {
  63. mixins: [wechatPay],
  64. data() {
  65. return {
  66. StaticUrl: this.$Static,
  67. isIphoneX: this.$store.state.isIphoneX,
  68. coupon: {},
  69. coupinList: [],
  70. userId: 0, // 机构Id
  71. couponId: 0, //优惠券Id
  72. payAmount: 100 ,//支付金额
  73. skeletonShow:true,
  74. contentModalText: '', //操作文字提示语句
  75. modal: false,
  76. modalButton: [
  77. {
  78. text: '取消',
  79. type: 'gray',
  80. plain: true //是否空心
  81. },
  82. {
  83. text: '去升级',
  84. customStyle: {
  85. color: '#fff',
  86. bgColor: 'linear-gradient(90deg, #F28F31 0%, #E15616 100%)'
  87. },
  88. plain: false
  89. }
  90. ],
  91. }
  92. },
  93. onLoad(option) {
  94. wxLogin.wxLoginAuthorize()
  95. this.userId = option.userId
  96. this.couponId = option.couponId
  97. console.log('机构userId', this.userId)
  98. console.log('价值优惠券Id', this.couponId)
  99. this.initCouponDetail(this.couponId)
  100. },
  101. filters: {
  102. TypeFormat(value) {
  103. switch (value) {
  104. case 0:
  105. return '活动券'
  106. break
  107. case 1:
  108. return '品类券'
  109. break
  110. case 2:
  111. return '用户专享券'
  112. break
  113. case 3:
  114. return '店铺券'
  115. break
  116. case 4:
  117. return '新用户券'
  118. break
  119. }
  120. }
  121. },
  122. computed: {
  123. ...mapState(['hasLogin', 'userInfo', 'identity', 'isActivity'])
  124. },
  125. methods: {
  126. initCouponDetail(couponId) {
  127. // 初始化优惠券信息
  128. this.ProductService.QueryCouponDetail({ couponId: couponId })
  129. .then(response => {
  130. this.coupon = response.data
  131. this.skeletonShow = false
  132. })
  133. .catch(error => {
  134. console.log('初始化优惠券信息异常~')
  135. })
  136. },
  137. createCouponRecord(){
  138. // 生成购买优惠券记录Id
  139. this.PayService.WeChatCouponRecord({
  140. userId: this.userId,
  141. couponId: this.couponId
  142. })
  143. .then(response => {
  144. this.MiniWxPayFor(response.data.couponRecordId)
  145. })
  146. .catch(error => {
  147. if(error.code == -1){//个人机构不能购买
  148. this.contentModalText ='该优惠券仅限医美机构购买,请升级为医美机构后再次购买。'
  149. this.modal = true
  150. }else if(error.code == -2){//会员机构不是医美机构不能购买
  151. this.$util.msg('该优惠券仅限医美机构购买', 2000)
  152. }
  153. })
  154. },
  155. async MiniWxPayFor(couponRecordId) {
  156. const wechatcode = await authorize.getCode('weixin')
  157. const params = {
  158. userId: this.userId,
  159. couponId: this.couponId,
  160. couponRecordId:couponRecordId,
  161. payType:'XCX',
  162. code: wechatcode,
  163. source: 1 //支付来源 1 小程序 2 WWW
  164. }
  165. this.weChatMiniCouponWxPay(params,'Um_Event_shareCouponPay','分享优惠券','线上支付优惠券',this.couponId,this.userId)
  166. },
  167. hideMobel(){
  168. this.modal = false
  169. },
  170. handleClick(e){
  171. //个人机构跳转升级页面
  172. if (e.index == 1) {
  173. this.$api.navigateTo('/pages/login/apply')
  174. }
  175. this.modal = false
  176. },
  177. navigator(url) {
  178. this.$api.navigateTo(url)
  179. }
  180. },
  181. onShow() {}
  182. }
  183. </script>
  184. <style lang="scss">
  185. page {
  186. background-color: #FFFFFF;
  187. }
  188. .container {
  189. width: 100%;
  190. height: auto;
  191. }
  192. .container-list {
  193. box-sizing: border-box;
  194. padding: 24rpx;
  195. .empty-container-image {
  196. width: 260rpx;
  197. height: 260rpx;
  198. margin-top: -300rpx;
  199. }
  200. .toIndexPage {
  201. bottom: 390rpx;
  202. }
  203. .coupon-list {
  204. width: 702rpx;
  205. height: 200rpx;
  206. box-sizing: border-box;
  207. background: url(https://static.caimei365.com/app/img/icon/icon-coupon-buy@2x.png) no-repeat;
  208. background-position: center;
  209. background-size: auto 200rpx;
  210. position: relative;
  211. .list-cell-le {
  212. width: 502rpx;
  213. height: 100%;
  214. box-sizing: border-box;
  215. padding: 23rpx 32rpx;
  216. float: left;
  217. .list-cell-tags {
  218. width: 100%;
  219. height: 32rpx;
  220. margin-bottom: 7rpx;
  221. .tags {
  222. display: inline-block;
  223. padding: 0 10rpx;
  224. height: 32rpx;
  225. line-height: 32rpx;
  226. background: linear-gradient(270deg, #f94b4b 0%, #feb673 100%);
  227. color: #ffffff;
  228. font-size: $font-size-22;
  229. border-radius: 8rpx;
  230. text-align: center;
  231. float: left;
  232. }
  233. }
  234. .list-cell-price {
  235. width: 100%;
  236. height: 45rpx;
  237. line-height: 45rpx;
  238. font-size: $font-size-32;
  239. color: #333333;
  240. text-align: left;
  241. margin-top: 10rpx;
  242. font-weight: bold;
  243. }
  244. .list-cell-texts {
  245. width: 100%;
  246. height: auto;
  247. line-height: 40rpx;
  248. text-overflow: ellipsis;
  249. display: -webkit-box;
  250. word-break: break-all;
  251. -webkit-box-orient: vertical;
  252. -webkit-line-clamp: 1;
  253. overflow: hidden;
  254. font-size: 26rpx;
  255. color: #333333;
  256. }
  257. .list-cell-time {
  258. width: 100%;
  259. height: 32rpx;
  260. line-height: 32rpx;
  261. text-align: left;
  262. font-size: $font-size-20;
  263. color: #999999;
  264. }
  265. }
  266. .list-cell-ri {
  267. width: 200rpx;
  268. height: 100%;
  269. box-sizing: border-box;
  270. padding: 58rpx 0 0 0;
  271. float: right;
  272. .coupon-maxMoney {
  273. width: 100%;
  274. height: 78rpx;
  275. line-height: 78rpx;
  276. font-size: 40rpx;
  277. color: #f94b4b;
  278. text-align: center;
  279. .small {
  280. font-size: $font-size-26;
  281. }
  282. }
  283. .coupon-minMoney {
  284. width: 100%;
  285. height: 33rpx;
  286. line-height: 33rpx;
  287. font-size: $font-size-26;
  288. color: #f94b4b;
  289. text-align: center;
  290. }
  291. }
  292. }
  293. }
  294. .container-button {
  295. width: 100%;
  296. height: 90rpx;
  297. margin-top: 190rpx;
  298. .button {
  299. width: 600rpx;
  300. height: 90rpx;
  301. text-align: center;
  302. background: $btn-confirm;
  303. line-height: 90rpx;
  304. font-size: $font-size-30;
  305. color: #ffffff;
  306. margin: 0 auto;
  307. border-radius: 45rpx;
  308. }
  309. }
  310. </style>