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