couponShare.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392
  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">
  7. <view class="use">¥<span class="use2">{{detail.actMoney}}</span></view>
  8. <!-- <view class="used" v-else>¥<span class="used2">{{detail.actMoney}}</span></view> -->
  9. <view class="tiaojian">{{detail.whereMoney!==0?'满'+detail.whereMoney+'元可用':'满任意金额可用'}}</view>
  10. </view>
  11. <view class="centerB">
  12. <view class="name">{{detail.actName}}</view>
  13. <view class="time" v-if="detail.startTime">
  14. 有效期:{{detail.startTime.slice(0,10)}}-{{detail.endTime.slice(0,10)}}</view>
  15. <view class="time" v-else>有效期:领取后{{detail.endOffsetDays}}天有效</view>
  16. </view>
  17. </view>
  18. </view>
  19. <view class="comtentBox">
  20. <view style="margin-bottom: 30rpx;">
  21. <!-- <view class="titleBox">
  22. <image src="../../static/img/icon_youhui_red.png" mode="" class="redPoint"></image>
  23. <view class="title">可用次数</view>
  24. </view>
  25. <view class="content">{{detail.avaQty}}次</view> -->
  26. </view>
  27. <view style="margin-bottom: 30rpx;">
  28. <view class="titleBox">
  29. <image src="../../static/img/icon_youhui_red.png" mode="" class="redPoint"></image>
  30. <view class="title">适用门店</view>
  31. </view>
  32. <view v-for="(v,index) in detail.shopNames.split(',')">
  33. <view class="content">{{v}}</view>
  34. </view>
  35. </view>
  36. <view>
  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 v-if="detail.couContent" v-html="detail.couContent"></view>
  42. <view v-else class="content">暂无</view>
  43. </view>
  44. </view>
  45. <view class="bottomBtn" :style="{background:'#'+themeColor}" @click="receive">领取</view>
  46. <!-- 手机号授权 -->
  47. <view class="authorizBox" v-if="authorizShow" @click="authorizShow=false">
  48. <view class="authorizCont" @click.stop="">
  49. <view class="authorizName">{{wxOpenData.miniAppName}}</view>
  50. <view class="authorizMs">您好,欢迎访问本店,授权手机号登录能获取我们最新的促销活动哦~</view>
  51. <button class="authorizContbutton" type="default" open-type="getPhoneNumber" @getphonenumber="decryptPhoneNumber">授权</button>
  52. </view>
  53. <view style="text-align: center;padding-top: 56rpx;">
  54. <image src="../../static/timg/icon_guanbi@2x.png" mode="" @click="hideSq" class="authorizCloseImg"></image>
  55. </view>
  56. </view>
  57. </view>
  58. </template>
  59. <script>
  60. export default {
  61. data() {
  62. return {
  63. id: '',
  64. detail: {},
  65. themeColor:'',
  66. type:'',
  67. authorizShow:false,
  68. userInfo:'',
  69. ext:'',
  70. wxOpenData:'',
  71. scene:'',
  72. }
  73. },
  74. onLoad(opt) {
  75. this.themeColor = uni.getStorageSync("themeColor");
  76. this.id = opt.id;
  77. this.type=opt.type;
  78. this.userInfo=this.$store.state.userInfo;
  79. this.ext=this.$common.getExtStoreId();
  80. //scene=2E03F5108B434EFABD70F2D208890209
  81. if(this.userInfo){
  82. if(opt.scene&&opt.scene!='undefined'){
  83. this.scene=opt.scene;
  84. this.getShareParams()
  85. }else{
  86. this.getData();
  87. }
  88. }else{
  89. this.$common.automaticlogin().then(val => {
  90. this.userInfo=this.$store.state.userInfo;
  91. this.wxOpenData=this.$store.state.wxOpenData;
  92. if(opt.scene&&opt.scene!='undefined'){
  93. this.scene=opt.scene;
  94. this.getShareParams()
  95. }else{
  96. this.getData();
  97. }
  98. if(!this.userInfo){
  99. this.authorizShow=true
  100. }
  101. })
  102. }
  103. },
  104. methods: {
  105. hideSq(){
  106. this.authorizShow=false;
  107. },
  108. getShareParams(){
  109. this.$http('openMall/getShareParamsCache', {
  110. scene:this.scene,
  111. },'GET').then(res => {
  112. var data= JSON.parse(res.data) ;
  113. console.log(data)
  114. this.id=data.couponId;
  115. this.getData();
  116. })
  117. },
  118. receive(id){
  119. uni.showLoading({
  120. title: '领取中'
  121. })
  122. this.$http('opencoupon/getCoupons', {
  123. id: this.id,
  124. }, 'GET').then(res => {
  125. /* uni.hideLoading();
  126. uni.showToast({
  127. title: '领取成功',
  128. icon:'none',
  129. duration: 3000
  130. }); */
  131. if(res.code==0){
  132. uni.showToast({
  133. title: '领取成功',
  134. icon:'none',
  135. duration: 3000
  136. });
  137. }
  138. //this.getData();
  139. })
  140. },
  141. getData() {
  142. uni.showLoading({
  143. title: '加载中'
  144. });
  145. if(this.type==2){
  146. var url='opencoupon/detailsCouponDetails';
  147. var params={
  148. id: this.id,
  149. custId:this.$store.state.wxOpenData.loginInfo.customerInfo.id
  150. }
  151. }else{
  152. var url='opencoupon/detailsCouponDetails'
  153. var params={
  154. id: this.id,
  155. }
  156. }
  157. this.$http(url, params, 'GET').then(res => {
  158. uni.hideLoading();
  159. this.detail = res.data;
  160. })
  161. },
  162. decryptPhoneNumber: function(e) {
  163. console.log(e);
  164. this.code=e.detail.code
  165. this.wxPhoneLogin()
  166. this.authorizShow=false;
  167. },
  168. wxPhoneLogin(){
  169. var that=this;
  170. this.$http('miniApp2/sys/wxPhoneLogin', {
  171. appId:this.ext.appId,
  172. unionId:this.ext.unionId,
  173. code:this.code,
  174. openId:this.wxOpenData.openid
  175. },'POST').then(res => {
  176. var data = res.data;
  177. if(data.loginInfo){
  178. this.userInfo=data.loginInfo.openUser;
  179. this.wxOpenData=data.loginInfo;
  180. this.$store.commit('mutationswxOpenData', data)
  181. this.$store.commit('mutationsuserInfo', this.userInfo)
  182. this.getData()
  183. }
  184. })
  185. },
  186. }
  187. }
  188. </script>
  189. <style scoped>
  190. .bottomBtn{
  191. width:704rpx;
  192. line-height: 88rpx;
  193. font-size: 30rpx;
  194. font-weight: 500;
  195. text-align: center;
  196. color: #FFFFFF;
  197. margin: 0 auto;
  198. margin-top: 80rpx;
  199. border-radius: 44rpx;
  200. }
  201. .boxtop{
  202. background: #FF0000;
  203. }
  204. .box {
  205. min-height: 100vh;
  206. background: #F4F5F7;
  207. }
  208. .detailBg {
  209. margin: -100rpx 24rpx 0rpx;
  210. background-color: #FFFFFF;
  211. border-radius: 10rpx;
  212. padding: 40rpx 20rpx;
  213. }
  214. .detailTop {
  215. display: flex;
  216. justify-content: flex-start;
  217. }
  218. .use {
  219. font-size: 26rpx;
  220. color: #FF0000;
  221. }
  222. .use2 {
  223. font-size: 40rpx;
  224. font-weight: 500;
  225. color: #FF0000;
  226. line-height: 56rpx;
  227. }
  228. .used {
  229. font-size: 26rpx;
  230. color: #666666;
  231. }
  232. .used2 {
  233. font-size: 40rpx;
  234. font-weight: 500;
  235. color: #666666;
  236. line-height: 56rpx;
  237. }
  238. .tiaojian {
  239. font-size: 24rpx;
  240. color: #666666;
  241. }
  242. .name {
  243. font-size: 30rpx;
  244. font-weight: 500;
  245. color: #333333;
  246. line-height: 56rpx;
  247. }
  248. .time {
  249. font-size: 24rpx;
  250. color: #666666;
  251. }
  252. .leftB {
  253. margin-right: 15rpx;
  254. }
  255. .comtentBox {
  256. margin: 20rpx 24rpx;
  257. background-color: #FFFFFF;
  258. border-radius: 10rpx;
  259. padding: 20rpx;
  260. }
  261. .titleBox {
  262. display: flex;
  263. align-items: center;
  264. }
  265. .redPoint {
  266. width: 18rpx;
  267. height: 18rpx;
  268. margin-right: 10rpx;
  269. }
  270. .title {
  271. font-size: 30rpx;
  272. color: #333333;
  273. font-weight: bold;
  274. }
  275. .content {
  276. font-size: 26rpx;
  277. color: #666666;
  278. margin-top: 16rpx;
  279. margin-left: 28rpx;
  280. }
  281. .authorizBox{
  282. width: 100vw;
  283. height: 100vh;
  284. background: rgba(0, 0, 0, 0.5);
  285. position: fixed;
  286. top: 0;
  287. left: 0;
  288. }
  289. .authorizCont{
  290. margin-top: 30vh;
  291. width: 564rpx;
  292. height: 408rpx;
  293. background: #FFFFFF;
  294. border-radius: 24rpx;
  295. margin-left: 93rpx;
  296. position: relative;
  297. }
  298. .authorizCloseImg{
  299. width: 62rpx;
  300. height: 62rpx;
  301. }
  302. .sqLogoBox{
  303. width: 180rpx;
  304. height: 180rpx;
  305. background: #FFFFFF;
  306. border-radius: 90rpx;
  307. text-align: center;
  308. position: absolute;
  309. top: -50rpx;
  310. left: 192rpx;
  311. }
  312. .authorizName{
  313. color: #333333;
  314. line-height: 42rpx;
  315. font-size: 30rpx;
  316. text-align: center;
  317. padding-top: 58rpx;
  318. }
  319. .authorizMs{
  320. color: #999999;
  321. line-height: 36rpx;
  322. font-size: 26rpx;
  323. width: 452rpx;
  324. padding-top: 24rpx;
  325. text-align: center;
  326. margin-left: 56rpx;
  327. }
  328. .authorizContbutton{
  329. width: 422rpx;
  330. height: 88rpx;
  331. background: #D53533;
  332. border-radius: 44rpx;
  333. line-height: 88rpx;
  334. text-align: center;
  335. font-size:30rpx;
  336. color: #FFFFFF;
  337. margin-top: 62rpx;
  338. margin-left:71rpx;
  339. }
  340. </style>