couponShare.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477
  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. }
  168. //this.getData();
  169. })
  170. },
  171. getData() {
  172. uni.showLoading({
  173. title: '加载中'
  174. });
  175. if(this.type==2){
  176. var url='opencoupon/detailsCouponDetails';
  177. var params={
  178. id: this.id,
  179. custId:this.$store.state.wxOpenData.loginInfo.customerInfo.id
  180. }
  181. }else{
  182. var url='opencoupon/detailsCouponDetails'
  183. var params={
  184. id: this.id,
  185. }
  186. }
  187. this.$http(url, params, 'GET').then(res => {
  188. uni.hideLoading();
  189. if(res.data.couContent){
  190. res.data.couContent=res.data.couContent.replaceAll('font-size:15px', 'font-size:12px');
  191. res.data.couContent=res.data.couContent.replaceAll('font-size: 15px', 'font-size:12px');
  192. res.data.couContent=res.data.couContent.replaceAll('font-size:14px', 'font-size:12px');
  193. }
  194. this.detail = res.data;
  195. })
  196. },
  197. decryptPhoneNumber: function(e) {
  198. console.log(e);
  199. this.code=e.detail.code
  200. this.wxPhoneLogin()
  201. this.authorizShow=false;
  202. },
  203. wxPhoneLogin(){
  204. var that=this;
  205. this.$http('miniApp2/sys/wxPhoneLogin', {
  206. appId:this.ext.appId,
  207. unionId:this.ext.unionId,
  208. code:this.code,
  209. openId:this.wxOpenData.openid
  210. },'POST').then(res => {
  211. var data = res.data;
  212. if(data.loginInfo){
  213. this.userInfo=data.loginInfo.openUser;
  214. this.wxOpenData=data.loginInfo;
  215. this.$store.commit('mutationswxOpenData', data)
  216. this.$store.commit('mutationsuserInfo', this.userInfo)
  217. this.getData()
  218. }
  219. })
  220. },
  221. }
  222. }
  223. </script>
  224. <style scoped>
  225. .djq{
  226. background: linear-gradient(128deg, #FFE4C5 0%, #FDC692 100%);
  227. border-radius: 4rpx;
  228. height: 34rpx;
  229. width: 76rpx;
  230. line-height: 34rpx;
  231. text-align: center;
  232. color: #2B2219;
  233. font-size: 20rpx;
  234. margin-top: 4rpx;
  235. margin-right: 10rpx;
  236. }
  237. .centerB{
  238. padding-top: 10rpx;
  239. }
  240. .chahaoImg{
  241. width: 36rpx;height: 36rpx;
  242. }
  243. .titleBox span{
  244. font-size: 12px;
  245. }
  246. .syShopBox{
  247. background: #FFFFFF;
  248. border-radius: 32rpx 32rpx 0rpx 0rpx;
  249. width: 750rpx;
  250. height: 80vh;
  251. margin-top: 20vh;
  252. }
  253. .spShopLineBox{
  254. height: calc(80vh - 90rpx);
  255. overflow-y: scroll;
  256. }
  257. .spShopLine{
  258. color: #333333;font-size: 26rpx;
  259. padding: 26rpx 30rpx;
  260. border-bottom: 1px solid #EEEEEE;
  261. }
  262. .chBox2{
  263. display: flex;justify-content: space-between;
  264. padding-left: 30rpx;
  265. padding-top: 30rpx;
  266. padding-right: 24rpx;
  267. padding-bottom: 10rpx;
  268. }
  269. .syShopTitle{
  270. font-weight: 500;
  271. color: #333333;
  272. font-size: 30rpx;
  273. line-height: 42rpx;
  274. }
  275. .bottomBtn{
  276. width:704rpx;
  277. line-height: 88rpx;
  278. font-size: 30rpx;
  279. font-weight: 500;
  280. text-align: center;
  281. color: #FFFFFF;
  282. margin: 0 auto;
  283. margin-top: 80rpx;
  284. border-radius: 44rpx;
  285. }
  286. .boxtop{
  287. background: #FF0000;
  288. }
  289. .box {
  290. min-height: 100vh;
  291. background: #F4F5F7;
  292. }
  293. .detailBg {
  294. margin: -100rpx 24rpx 0rpx;
  295. background-color: #FFFFFF;
  296. border-radius: 10rpx;
  297. padding: 40rpx 20rpx;
  298. }
  299. .detailTop {
  300. display: flex;
  301. justify-content: flex-start;
  302. }
  303. .use {
  304. font-size: 26rpx;
  305. color: #FF0000;
  306. }
  307. .use2 {
  308. font-size: 40rpx;
  309. font-weight: 500;
  310. color: #FF0000;
  311. line-height: 56rpx;
  312. }
  313. .used {
  314. font-size: 26rpx;
  315. color: #666666;
  316. }
  317. .used2 {
  318. font-size: 40rpx;
  319. font-weight: 500;
  320. color: #666666;
  321. line-height: 56rpx;
  322. }
  323. .tiaojian {
  324. font-size: 24rpx;
  325. color: #666666;
  326. }
  327. .name {
  328. font-size: 30rpx;
  329. font-weight: 500;
  330. color: #333333;
  331. line-height: 56rpx;
  332. }
  333. .time {
  334. font-size: 24rpx;
  335. color: #666666;
  336. }
  337. .leftB {
  338. margin-right: 15rpx;
  339. }
  340. .comtentBox {
  341. margin: 20rpx 24rpx;
  342. background-color: #FFFFFF;
  343. border-radius: 10rpx;
  344. padding: 20rpx;
  345. }
  346. .titleBox {
  347. display: flex;
  348. align-items: center;
  349. }
  350. .redPoint {
  351. width: 18rpx;
  352. height: 18rpx;
  353. margin-right: 10rpx;
  354. }
  355. .title {
  356. font-size: 30rpx;
  357. color: #333333;
  358. font-weight: bold;
  359. }
  360. .content {
  361. font-size: 26rpx;
  362. color: #666666;
  363. margin-top: 16rpx;
  364. margin-left: 28rpx;
  365. }
  366. .authorizBox{
  367. width: 100vw;
  368. height: 100vh;
  369. background: rgba(0, 0, 0, 0.5);
  370. position: fixed;
  371. top: 0;
  372. left: 0;
  373. }
  374. .authorizCont{
  375. margin-top: 30vh;
  376. width: 564rpx;
  377. height: 408rpx;
  378. background: #FFFFFF;
  379. border-radius: 24rpx;
  380. margin-left: 93rpx;
  381. position: relative;
  382. }
  383. .authorizCloseImg{
  384. width: 62rpx;
  385. height: 62rpx;
  386. }
  387. .sqLogoBox{
  388. width: 180rpx;
  389. height: 180rpx;
  390. background: #FFFFFF;
  391. border-radius: 90rpx;
  392. text-align: center;
  393. position: absolute;
  394. top: -50rpx;
  395. left: 192rpx;
  396. }
  397. .authorizName{
  398. color: #333333;
  399. line-height: 42rpx;
  400. font-size: 30rpx;
  401. text-align: center;
  402. padding-top: 58rpx;
  403. }
  404. .authorizMs{
  405. color: #999999;
  406. line-height: 36rpx;
  407. font-size: 26rpx;
  408. width: 452rpx;
  409. padding-top: 24rpx;
  410. text-align: center;
  411. margin-left: 56rpx;
  412. }
  413. .authorizContbutton{
  414. width: 422rpx;
  415. height: 88rpx;
  416. background: #D53533;
  417. border-radius: 44rpx;
  418. line-height: 88rpx;
  419. text-align: center;
  420. font-size:30rpx;
  421. color: #FFFFFF;
  422. margin-top: 62rpx;
  423. margin-left:71rpx;
  424. }
  425. </style>