couponShare.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488
  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. ShopID:'',
  97. }
  98. },
  99. onLoad(opt) {
  100. this.themeColor = uni.getStorageSync("themeColor");
  101. this.id = opt.id;
  102. this.type=opt.type;
  103. this.userInfo=this.$store.state.userInfo;
  104. this.ext=this.$common.getExtStoreId();
  105. if(this.userInfo){
  106. //this.scene='2E03F5108B434EFABD70F2D208890209'
  107. if(opt.scene&&opt.scene!='undefined'){
  108. this.scene=opt.scene;
  109. this.getShareParams()
  110. }else{
  111. this.getData();
  112. }
  113. }else{
  114. this.$common.automaticlogin().then(val => {
  115. this.userInfo=this.$store.state.userInfo;
  116. this.wxOpenData=this.$store.state.wxOpenData;
  117. if(opt.scene&&opt.scene!='undefined'){
  118. this.scene=opt.scene;
  119. this.getShareParams()
  120. }else{
  121. this.getData();
  122. }
  123. if(!this.userInfo){
  124. this.authorizShow=true
  125. }
  126. })
  127. }
  128. },
  129. methods: {
  130. spShopHide(){
  131. this.spShopShow=false;
  132. },
  133. spShopS(){
  134. this.spShopShow=true;
  135. },
  136. hideSq(){
  137. this.authorizShow=false;
  138. },
  139. getShareParams(){
  140. this.$http('openMall/getShareParamsCache', {
  141. scene:this.scene,
  142. },'GET').then(res => {
  143. var data= JSON.parse(res.data) ;
  144. console.log(data)
  145. this.id=data.couponId;
  146. this.ShopID=data.ShopID
  147. this.getData();
  148. })
  149. },
  150. receive(id){
  151. uni.showLoading({
  152. title: '领取中'
  153. })
  154. this.$http('opencoupon/getCoupons', {
  155. id: this.id,
  156. ShopID:this.ShopID
  157. }, 'GET').then(res => {
  158. /* uni.hideLoading();
  159. uni.showToast({
  160. title: '领取成功',
  161. icon:'none',
  162. duration: 3000
  163. }); */
  164. if(res.code==0){
  165. uni.showToast({
  166. title: '领取成功',
  167. icon:'none',
  168. duration: 3000
  169. });
  170. setTimeout(function() {
  171. uni.switchTab({
  172. url:'../index/index'
  173. })
  174. }, 2000);
  175. }
  176. //this.getData();
  177. })
  178. },
  179. getData() {
  180. uni.showLoading({
  181. title: '加载中'
  182. });
  183. if(this.type==2){
  184. var url='opencoupon/detailsCouponDetails';
  185. var params={
  186. id: this.id,
  187. custId:this.$store.state.wxOpenData.loginInfo.customerInfo.id
  188. }
  189. }else{
  190. var url='opencoupon/detailsCouponDetails'
  191. var params={
  192. id: this.id,
  193. }
  194. }
  195. this.$http(url, params, 'GET').then(res => {
  196. uni.hideLoading();
  197. if(res.data.couContent){
  198. res.data.couContent=res.data.couContent.replaceAll('font-size:15px', 'font-size:12px');
  199. res.data.couContent=res.data.couContent.replaceAll('font-size: 15px', 'font-size:12px');
  200. res.data.couContent=res.data.couContent.replaceAll('font-size:14px', 'font-size:12px');
  201. }
  202. this.detail = res.data;
  203. })
  204. },
  205. decryptPhoneNumber: function(e) {
  206. console.log(e);
  207. this.code=e.detail.code
  208. this.wxPhoneLogin()
  209. this.authorizShow=false;
  210. },
  211. wxPhoneLogin(){
  212. var that=this;
  213. this.$http('miniApp2/sys/wxPhoneLogin', {
  214. appId:this.ext.appId,
  215. unionId:this.ext.unionId,
  216. code:this.code,
  217. openId:this.wxOpenData.openid
  218. },'POST').then(res => {
  219. var data = res.data;
  220. if(data.loginInfo){
  221. this.userInfo=data.loginInfo.openUser;
  222. this.wxOpenData=data.loginInfo;
  223. this.$store.commit('mutationswxOpenData', data)
  224. this.$store.commit('mutationsuserInfo', this.userInfo)
  225. this.getData()
  226. }
  227. })
  228. },
  229. }
  230. }
  231. </script>
  232. <style scoped>
  233. .djq{
  234. background: linear-gradient(128deg, #FFE4C5 0%, #FDC692 100%);
  235. border-radius: 4rpx;
  236. height: 34rpx;
  237. width: 76rpx;
  238. line-height: 34rpx;
  239. text-align: center;
  240. color: #2B2219;
  241. font-size: 20rpx;
  242. margin-top: 4rpx;
  243. margin-right: 10rpx;
  244. }
  245. .centerB{
  246. padding-top: 10rpx;
  247. }
  248. .chahaoImg{
  249. width: 36rpx;height: 36rpx;
  250. }
  251. .titleBox span{
  252. font-size: 12px;
  253. }
  254. .syShopBox{
  255. background: #FFFFFF;
  256. border-radius: 32rpx 32rpx 0rpx 0rpx;
  257. width: 750rpx;
  258. height: 80vh;
  259. margin-top: 20vh;
  260. }
  261. .spShopLineBox{
  262. height: calc(80vh - 90rpx);
  263. overflow-y: scroll;
  264. }
  265. .spShopLine{
  266. color: #333333;font-size: 26rpx;
  267. padding: 26rpx 30rpx;
  268. border-bottom: 1px solid #EEEEEE;
  269. }
  270. .chBox2{
  271. display: flex;justify-content: space-between;
  272. padding-left: 30rpx;
  273. padding-top: 30rpx;
  274. padding-right: 24rpx;
  275. padding-bottom: 10rpx;
  276. }
  277. .syShopTitle{
  278. font-weight: 500;
  279. color: #333333;
  280. font-size: 30rpx;
  281. line-height: 42rpx;
  282. }
  283. .bottomBtn{
  284. width:704rpx;
  285. line-height: 88rpx;
  286. font-size: 30rpx;
  287. font-weight: 500;
  288. text-align: center;
  289. color: #FFFFFF;
  290. margin: 0 auto;
  291. margin-top: 80rpx;
  292. border-radius: 44rpx;
  293. }
  294. .boxtop{
  295. background: #EC0F0A;
  296. }
  297. .box {
  298. min-height: 100vh;
  299. background: #F4F5F7;
  300. }
  301. .detailBg {
  302. margin: -100rpx 24rpx 0rpx;
  303. background-color: #FFFFFF;
  304. border-radius: 10rpx;
  305. padding: 40rpx 20rpx;
  306. }
  307. .detailTop {
  308. display: flex;
  309. justify-content: flex-start;
  310. }
  311. .use {
  312. font-size: 26rpx;
  313. color: #EC0F0A;
  314. }
  315. .use2 {
  316. font-size: 40rpx;
  317. font-weight: 500;
  318. color: #EC0F0A;
  319. line-height: 56rpx;
  320. }
  321. .used {
  322. font-size: 26rpx;
  323. color: #666666;
  324. }
  325. .used2 {
  326. font-size: 40rpx;
  327. font-weight: 500;
  328. color: #666666;
  329. line-height: 56rpx;
  330. }
  331. .tiaojian {
  332. font-size: 24rpx;
  333. color: #666666;
  334. }
  335. .name {
  336. font-size: 30rpx;
  337. font-weight: 500;
  338. color: #333333;
  339. line-height: 56rpx;
  340. }
  341. .time {
  342. font-size: 24rpx;
  343. color: #666666;
  344. }
  345. .leftB {
  346. margin-right: 15rpx;
  347. }
  348. .comtentBox {
  349. margin: 20rpx 24rpx;
  350. background-color: #FFFFFF;
  351. border-radius: 10rpx;
  352. padding: 20rpx;
  353. }
  354. .titleBox {
  355. display: flex;
  356. align-items: center;
  357. }
  358. .redPoint {
  359. width: 18rpx;
  360. height: 18rpx;
  361. margin-right: 10rpx;
  362. }
  363. .title {
  364. font-size: 30rpx;
  365. color: #333333;
  366. font-weight: bold;
  367. }
  368. .content {
  369. font-size: 26rpx;
  370. color: #666666;
  371. margin-top: 16rpx;
  372. margin-left: 28rpx;
  373. }
  374. .authorizBox{
  375. width: 100vw;
  376. height: 100vh;
  377. background: rgba(0, 0, 0, 0.5);
  378. position: fixed;
  379. top: 0;
  380. left: 0;
  381. }
  382. .authorizCont{
  383. margin-top: 30vh;
  384. width: 564rpx;
  385. height: 408rpx;
  386. background: #FFFFFF;
  387. border-radius: 24rpx;
  388. margin-left: 93rpx;
  389. position: relative;
  390. }
  391. .authorizCloseImg{
  392. width: 62rpx;
  393. height: 62rpx;
  394. }
  395. .sqLogoBox{
  396. width: 180rpx;
  397. height: 180rpx;
  398. background: #FFFFFF;
  399. border-radius: 90rpx;
  400. text-align: center;
  401. position: absolute;
  402. top: -50rpx;
  403. left: 192rpx;
  404. }
  405. .authorizName{
  406. color: #333333;
  407. line-height: 42rpx;
  408. font-size: 30rpx;
  409. text-align: center;
  410. padding-top: 58rpx;
  411. }
  412. .authorizMs{
  413. color: #999999;
  414. line-height: 36rpx;
  415. font-size: 26rpx;
  416. width: 452rpx;
  417. padding-top: 24rpx;
  418. text-align: center;
  419. margin-left: 56rpx;
  420. }
  421. .authorizContbutton{
  422. width: 422rpx;
  423. height: 88rpx;
  424. background: #EC0F0A;
  425. border-radius: 44rpx;
  426. line-height: 88rpx;
  427. text-align: center;
  428. font-size:30rpx;
  429. color: #FFFFFF;
  430. margin-top: 62rpx;
  431. margin-left:71rpx;
  432. }
  433. </style>