couponShare.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484
  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.loginInfo){
  218. this.userInfo=data.loginInfo.openUser;
  219. this.wxOpenData=data.loginInfo;
  220. this.$store.commit('mutationswxOpenData', data)
  221. this.$store.commit('mutationsuserInfo', this.userInfo)
  222. this.getData()
  223. }
  224. })
  225. },
  226. }
  227. }
  228. </script>
  229. <style scoped>
  230. .djq{
  231. background: linear-gradient(128deg, #FFE4C5 0%, #FDC692 100%);
  232. border-radius: 4rpx;
  233. height: 34rpx;
  234. width: 76rpx;
  235. line-height: 34rpx;
  236. text-align: center;
  237. color: #2B2219;
  238. font-size: 20rpx;
  239. margin-top: 4rpx;
  240. margin-right: 10rpx;
  241. }
  242. .centerB{
  243. padding-top: 10rpx;
  244. }
  245. .chahaoImg{
  246. width: 36rpx;height: 36rpx;
  247. }
  248. .titleBox span{
  249. font-size: 12px;
  250. }
  251. .syShopBox{
  252. background: #FFFFFF;
  253. border-radius: 32rpx 32rpx 0rpx 0rpx;
  254. width: 750rpx;
  255. height: 80vh;
  256. margin-top: 20vh;
  257. }
  258. .spShopLineBox{
  259. height: calc(80vh - 90rpx);
  260. overflow-y: scroll;
  261. }
  262. .spShopLine{
  263. color: #333333;font-size: 26rpx;
  264. padding: 26rpx 30rpx;
  265. border-bottom: 1px solid #EEEEEE;
  266. }
  267. .chBox2{
  268. display: flex;justify-content: space-between;
  269. padding-left: 30rpx;
  270. padding-top: 30rpx;
  271. padding-right: 24rpx;
  272. padding-bottom: 10rpx;
  273. }
  274. .syShopTitle{
  275. font-weight: 500;
  276. color: #333333;
  277. font-size: 30rpx;
  278. line-height: 42rpx;
  279. }
  280. .bottomBtn{
  281. width:704rpx;
  282. line-height: 88rpx;
  283. font-size: 30rpx;
  284. font-weight: 500;
  285. text-align: center;
  286. color: #FFFFFF;
  287. margin: 0 auto;
  288. margin-top: 80rpx;
  289. border-radius: 44rpx;
  290. }
  291. .boxtop{
  292. background: #FF0000;
  293. }
  294. .box {
  295. min-height: 100vh;
  296. background: #F4F5F7;
  297. }
  298. .detailBg {
  299. margin: -100rpx 24rpx 0rpx;
  300. background-color: #FFFFFF;
  301. border-radius: 10rpx;
  302. padding: 40rpx 20rpx;
  303. }
  304. .detailTop {
  305. display: flex;
  306. justify-content: flex-start;
  307. }
  308. .use {
  309. font-size: 26rpx;
  310. color: #FF0000;
  311. }
  312. .use2 {
  313. font-size: 40rpx;
  314. font-weight: 500;
  315. color: #FF0000;
  316. line-height: 56rpx;
  317. }
  318. .used {
  319. font-size: 26rpx;
  320. color: #666666;
  321. }
  322. .used2 {
  323. font-size: 40rpx;
  324. font-weight: 500;
  325. color: #666666;
  326. line-height: 56rpx;
  327. }
  328. .tiaojian {
  329. font-size: 24rpx;
  330. color: #666666;
  331. }
  332. .name {
  333. font-size: 30rpx;
  334. font-weight: 500;
  335. color: #333333;
  336. line-height: 56rpx;
  337. }
  338. .time {
  339. font-size: 24rpx;
  340. color: #666666;
  341. }
  342. .leftB {
  343. margin-right: 15rpx;
  344. }
  345. .comtentBox {
  346. margin: 20rpx 24rpx;
  347. background-color: #FFFFFF;
  348. border-radius: 10rpx;
  349. padding: 20rpx;
  350. }
  351. .titleBox {
  352. display: flex;
  353. align-items: center;
  354. }
  355. .redPoint {
  356. width: 18rpx;
  357. height: 18rpx;
  358. margin-right: 10rpx;
  359. }
  360. .title {
  361. font-size: 30rpx;
  362. color: #333333;
  363. font-weight: bold;
  364. }
  365. .content {
  366. font-size: 26rpx;
  367. color: #666666;
  368. margin-top: 16rpx;
  369. margin-left: 28rpx;
  370. }
  371. .authorizBox{
  372. width: 100vw;
  373. height: 100vh;
  374. background: rgba(0, 0, 0, 0.5);
  375. position: fixed;
  376. top: 0;
  377. left: 0;
  378. }
  379. .authorizCont{
  380. margin-top: 30vh;
  381. width: 564rpx;
  382. height: 408rpx;
  383. background: #FFFFFF;
  384. border-radius: 24rpx;
  385. margin-left: 93rpx;
  386. position: relative;
  387. }
  388. .authorizCloseImg{
  389. width: 62rpx;
  390. height: 62rpx;
  391. }
  392. .sqLogoBox{
  393. width: 180rpx;
  394. height: 180rpx;
  395. background: #FFFFFF;
  396. border-radius: 90rpx;
  397. text-align: center;
  398. position: absolute;
  399. top: -50rpx;
  400. left: 192rpx;
  401. }
  402. .authorizName{
  403. color: #333333;
  404. line-height: 42rpx;
  405. font-size: 30rpx;
  406. text-align: center;
  407. padding-top: 58rpx;
  408. }
  409. .authorizMs{
  410. color: #999999;
  411. line-height: 36rpx;
  412. font-size: 26rpx;
  413. width: 452rpx;
  414. padding-top: 24rpx;
  415. text-align: center;
  416. margin-left: 56rpx;
  417. }
  418. .authorizContbutton{
  419. width: 422rpx;
  420. height: 88rpx;
  421. background: #D53533;
  422. border-radius: 44rpx;
  423. line-height: 88rpx;
  424. text-align: center;
  425. font-size:30rpx;
  426. color: #FFFFFF;
  427. margin-top: 62rpx;
  428. margin-left:71rpx;
  429. }
  430. </style>