couponShare.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499
  1. <template>
  2. <view class="box">
  3. <view style="width: 750rpx;height: 172rpx;" class="boxtop" :style="{background:'#'+themeColor}"></view>
  4. <view class="detailBg">
  5. <view class="detailTop">
  6. <view class="leftB" v-if="detail.discountType==1">
  7. <view class="use">¥<span class="use2">{{detail.actMoney}}</span></view>
  8. <view class="tiaojian">{{detail.whereMoney!==0?'满'+detail.whereMoney+'元可用':'满任意金额可用'}}</view>
  9. </view>
  10. <view v-if="detail.discountType!=1" class="leftB" style="display: flex;align-items: center;justify-content: center;">
  11. <image src="http://dmsphoto.66km.com.cn/thFiles/5340A784-FEE2-43FA-8ED1-C509FADFDBED.png"
  12. mode="" style="width: 77rpx;height:48rpx;"></image>
  13. </view>
  14. <view class="centerB">
  15. <view class="name">
  16. <span class="djq" v-if="detail.discountType==1">代金券</span>
  17. <span class="djq" v-if="detail.discountType==2">商品券</span>
  18. <span class="djq" v-if="detail.discountType==3">服务券</span>
  19. <span>{{detail.actName}}</span>
  20. </view>
  21. <view class="time" v-if="detail.startTime">
  22. 有效期:{{detail.startTime.slice(0,10)}}至{{detail.endTime.slice(0,10)}}</view>
  23. <view class="time" v-else>有效期:领取后{{detail.endOffsetDays}}天有效</view>
  24. </view>
  25. </view>
  26. </view>
  27. <view class="comtentBox">
  28. <view style="margin-bottom: 30rpx;">
  29. <!-- <view class="titleBox">
  30. <image src="../../static/img/icon_youhui_red.png" mode="" class="redPoint"></image>
  31. <view class="title">可用次数</view>
  32. </view>
  33. <view class="content">{{detail.avaQty}}次</view> -->
  34. </view>
  35. <view style="margin-bottom: 30rpx;">
  36. <view style="display: flex;justify-content: space-between;">
  37. <view class="titleBox">
  38. <image src="../../static/img/icon_youhui_red.png" mode="" class="redPoint"></image>
  39. <view class="title">适用门店</view>
  40. </view>
  41. <view @click="spShopS" style="color: #666666;font-size: 24rpx;line-height: 24rpx;display: flex;">
  42. {{detail.shopNames.split(',').length}}家门店通用
  43. <image src="../../static/img/little_rightArrow.png" mode="" style="width: 24rpx;height: 24rpx;"></image>
  44. </view>
  45. </view>
  46. </view>
  47. <view>
  48. <view class="titleBox">
  49. <image src="../../static/img/icon_youhui_red.png" mode="" class="redPoint"></image>
  50. <view class="title">使用说明</view>
  51. </view>
  52. <view v-if="detail.couContent" v-html="detail.couContent"></view>
  53. <view v-else class="content">暂无</view>
  54. </view>
  55. </view>
  56. <view class="bottomBtn" :style="{background:'#'+themeColor}" @click="receive">领取</view>
  57. <!-- 手机号授权 -->
  58. <view class="authorizBox" v-if="authorizShow" @click="authorizShow=false">
  59. <view class="authorizCont" @click.stop="">
  60. <view class="authorizName">{{wxOpenData.miniAppName}}</view>
  61. <view class="authorizMs">您好,欢迎访问本店,授权手机号登录能获取我们最新的促销活动哦~</view>
  62. <button class="authorizContbutton" type="default" open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber">授权</button>
  63. </view>
  64. <view style="text-align: center;padding-top: 56rpx;">
  65. <image src="../../static/timg/icon_guanbi@2x.png" mode="" @click="hideSq" class="authorizCloseImg"></image>
  66. </view>
  67. </view>
  68. <!-- 适用门店 -->
  69. <view class="authorizBox" v-if="spShopShow" @click="spShopHide">
  70. <view class="syShopBox" @click.stop="">
  71. <view class="chBox2">
  72. <view class="syShopTitle">适用门店</view>
  73. <img src="../../static/timg/chahao.png" alt="" class="chahaoImg" @click="spShopHide"/>
  74. </view>
  75. <view class="spShopLineBox">
  76. <view class="spShopLine" v-for="(item,index) in detail.shopNames.split(',')">{{item}}</view>
  77. </view>
  78. </view>
  79. </view>
  80. </view>
  81. </template>
  82. <script>
  83. export default {
  84. data() {
  85. return {
  86. id: '',
  87. detail: {},
  88. themeColor:'',
  89. type:'',
  90. authorizShow:false,
  91. userInfo:'',
  92. ext:'',
  93. wxOpenData:'',
  94. scene:'',
  95. spShopShow:false,
  96. }
  97. },
  98. onLoad(opt) {
  99. this.themeColor = uni.getStorageSync("themeColor");
  100. this.id = opt.id;
  101. this.type=opt.type;
  102. this.userInfo=this.$store.state.userInfo;
  103. this.ext=this.$common.getExtStoreId();
  104. //scene=2E03F5108B434EFABD70F2D208890209
  105. if(this.userInfo){
  106. if(opt.scene&&opt.scene!='undefined'){
  107. this.scene=opt.scene;
  108. this.getShareParams()
  109. }else{
  110. this.getData();
  111. }
  112. }else{
  113. this.$common.automaticlogin().then(val => {
  114. this.userInfo=this.$store.state.userInfo;
  115. this.wxOpenData=this.$store.state.wxOpenData;
  116. if(opt.scene&&opt.scene!='undefined'){
  117. this.scene=opt.scene;
  118. this.getShareParams()
  119. }else{
  120. this.getData();
  121. }
  122. if(!this.userInfo){
  123. this.authorizShow=true
  124. }
  125. })
  126. }
  127. },
  128. methods: {
  129. spShopHide(){
  130. this.spShopShow=false;
  131. },
  132. spShopS(){
  133. this.spShopShow=true;
  134. },
  135. hideSq(){
  136. this.authorizShow=false;
  137. },
  138. getShareParams(){
  139. this.$http('openMall/getShareParamsCache', {
  140. scene:this.scene,
  141. },'GET').then(res => {
  142. var data= JSON.parse(res.data) ;
  143. console.log(data)
  144. this.id=data.couponId;
  145. this.getData();
  146. })
  147. },
  148. receive(id){
  149. uni.showLoading({
  150. title: '领取中'
  151. })
  152. this.$http('opencoupon/getCoupons', {
  153. id: this.id,
  154. }, 'GET').then(res => {
  155. /* uni.hideLoading();
  156. uni.showToast({
  157. title: '领取成功',
  158. icon:'none',
  159. duration: 3000
  160. }); */
  161. if(res.code==0){
  162. uni.showToast({
  163. title: '领取成功',
  164. icon:'none',
  165. duration: 3000
  166. });
  167. setTimeout(function() {
  168. uni.switchTab({
  169. url:'../index/index'
  170. })
  171. }, 2000);
  172. }
  173. //this.getData();
  174. })
  175. },
  176. getData() {
  177. uni.showLoading({
  178. title: '加载中'
  179. });
  180. if(this.type==2){
  181. var url='opencoupon/detailsCouponDetails';
  182. var params={
  183. id: this.id,
  184. custId:this.$store.state.wxOpenData.loginInfo.customerInfo.id
  185. }
  186. }else{
  187. var url='opencoupon/detailsCouponDetails'
  188. var params={
  189. id: this.id,
  190. }
  191. }
  192. this.$http(url, params, 'GET').then(res => {
  193. uni.hideLoading();
  194. if(res.data.couContent){
  195. res.data.couContent=res.data.couContent.replaceAll('font-size:15px', 'font-size:12px');
  196. res.data.couContent=res.data.couContent.replaceAll('font-size: 15px', 'font-size:12px');
  197. res.data.couContent=res.data.couContent.replaceAll('font-size:14px', 'font-size:12px');
  198. }
  199. this.detail = res.data;
  200. })
  201. },
  202. decryptPhoneNumber: function(e) {
  203. console.log(e);
  204. this.code=e.detail.code
  205. this.wxPhoneLogin()
  206. this.authorizShow=false;
  207. },
  208. wxPhoneLogin(){
  209. var that=this;
  210. this.$http('miniApp2/sys/wxPhoneLogin', {
  211. appId:this.ext.appId,
  212. unionId:this.ext.unionId,
  213. code:this.code,
  214. openId:this.wxOpenData.openid
  215. },'POST').then(res => {
  216. var data = res.data;
  217. if(data.newCustomer){
  218. uni.showModal({
  219. title: '提示',
  220. content: data.newCustomerMsg,
  221. success: function(resTK) {
  222. }
  223. });
  224. var token=res.data.token
  225. data.loginInfo={}
  226. data.loginInfo.token=token
  227. this.$store.commit('mutationswxOpenData', data);
  228. return false;
  229. }
  230. if(data.loginInfo){
  231. this.userInfo=data.loginInfo.openUser;
  232. this.wxOpenData=data.loginInfo;
  233. this.$store.commit('mutationswxOpenData', data)
  234. this.$store.commit('mutationsuserInfo', this.userInfo)
  235. this.getData()
  236. }
  237. })
  238. },
  239. }
  240. }
  241. </script>
  242. <style scoped>
  243. .djq{
  244. background: linear-gradient(128deg, #FFE4C5 0%, #FDC692 100%);
  245. border-radius: 4rpx;
  246. height: 34rpx;
  247. width: 76rpx;
  248. line-height: 34rpx;
  249. text-align: center;
  250. color: #2B2219;
  251. font-size: 20rpx;
  252. margin-top: 4rpx;
  253. margin-right: 10rpx;
  254. }
  255. .centerB{
  256. padding-top: 10rpx;
  257. }
  258. .chahaoImg{
  259. width: 36rpx;height: 36rpx;
  260. }
  261. .titleBox span{
  262. font-size: 12px;
  263. }
  264. .syShopBox{
  265. background: #FFFFFF;
  266. border-radius: 32rpx 32rpx 0rpx 0rpx;
  267. width: 750rpx;
  268. height: 80vh;
  269. margin-top: 20vh;
  270. }
  271. .spShopLineBox{
  272. height: calc(80vh - 90rpx);
  273. overflow-y: scroll;
  274. }
  275. .spShopLine{
  276. color: #333333;font-size: 26rpx;
  277. padding: 26rpx 30rpx;
  278. border-bottom: 1px solid #EEEEEE;
  279. }
  280. .chBox2{
  281. display: flex;justify-content: space-between;
  282. padding-left: 30rpx;
  283. padding-top: 30rpx;
  284. padding-right: 24rpx;
  285. padding-bottom: 10rpx;
  286. }
  287. .syShopTitle{
  288. font-weight: 500;
  289. color: #333333;
  290. font-size: 30rpx;
  291. line-height: 42rpx;
  292. }
  293. .bottomBtn{
  294. width:704rpx;
  295. line-height: 88rpx;
  296. font-size: 30rpx;
  297. font-weight: 500;
  298. text-align: center;
  299. color: #FFFFFF;
  300. margin: 0 auto;
  301. margin-top: 80rpx;
  302. border-radius: 44rpx;
  303. }
  304. .boxtop{
  305. background: #FF0000;
  306. }
  307. .box {
  308. min-height: 100vh;
  309. background: #F4F5F7;
  310. }
  311. .detailBg {
  312. margin: -100rpx 24rpx 0rpx;
  313. background-color: #FFFFFF;
  314. border-radius: 10rpx;
  315. padding: 40rpx 20rpx;
  316. }
  317. .detailTop {
  318. display: flex;
  319. justify-content: flex-start;
  320. }
  321. .use {
  322. font-size: 26rpx;
  323. color: #FF0000;
  324. }
  325. .use2 {
  326. font-size: 40rpx;
  327. font-weight: 500;
  328. color: #FF0000;
  329. line-height: 56rpx;
  330. }
  331. .used {
  332. font-size: 26rpx;
  333. color: #666666;
  334. }
  335. .used2 {
  336. font-size: 40rpx;
  337. font-weight: 500;
  338. color: #666666;
  339. line-height: 56rpx;
  340. }
  341. .tiaojian {
  342. font-size: 24rpx;
  343. color: #666666;
  344. }
  345. .name {
  346. font-size: 30rpx;
  347. font-weight: 500;
  348. color: #333333;
  349. line-height: 56rpx;
  350. }
  351. .time {
  352. font-size: 24rpx;
  353. color: #666666;
  354. }
  355. .leftB {
  356. margin-right: 15rpx;
  357. }
  358. .comtentBox {
  359. margin: 20rpx 24rpx;
  360. background-color: #FFFFFF;
  361. border-radius: 10rpx;
  362. padding: 20rpx;
  363. }
  364. .titleBox {
  365. display: flex;
  366. align-items: center;
  367. }
  368. .redPoint {
  369. width: 18rpx;
  370. height: 18rpx;
  371. margin-right: 10rpx;
  372. }
  373. .title {
  374. font-size: 30rpx;
  375. color: #333333;
  376. font-weight: bold;
  377. }
  378. .content {
  379. font-size: 26rpx;
  380. color: #666666;
  381. margin-top: 16rpx;
  382. margin-left: 28rpx;
  383. }
  384. .authorizBox{
  385. width: 100vw;
  386. height: 100vh;
  387. background: rgba(0, 0, 0, 0.5);
  388. position: fixed;
  389. top: 0;
  390. left: 0;
  391. }
  392. .authorizCont{
  393. margin-top: 30vh;
  394. width: 564rpx;
  395. height: 408rpx;
  396. background: #FFFFFF;
  397. border-radius: 24rpx;
  398. margin-left: 93rpx;
  399. position: relative;
  400. }
  401. .authorizCloseImg{
  402. width: 62rpx;
  403. height: 62rpx;
  404. }
  405. .sqLogoBox{
  406. width: 180rpx;
  407. height: 180rpx;
  408. background: #FFFFFF;
  409. border-radius: 90rpx;
  410. text-align: center;
  411. position: absolute;
  412. top: -50rpx;
  413. left: 192rpx;
  414. }
  415. .authorizName{
  416. color: #333333;
  417. line-height: 42rpx;
  418. font-size: 30rpx;
  419. text-align: center;
  420. padding-top: 58rpx;
  421. }
  422. .authorizMs{
  423. color: #999999;
  424. line-height: 36rpx;
  425. font-size: 26rpx;
  426. width: 452rpx;
  427. padding-top: 24rpx;
  428. text-align: center;
  429. margin-left: 56rpx;
  430. }
  431. .authorizContbutton{
  432. width: 422rpx;
  433. height: 88rpx;
  434. background: #D53533;
  435. border-radius: 44rpx;
  436. line-height: 88rpx;
  437. text-align: center;
  438. font-size:30rpx;
  439. color: #FFFFFF;
  440. margin-top: 62rpx;
  441. margin-left:71rpx;
  442. }
  443. </style>