couponShare.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  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="" 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. getShareParams(){
  106. this.$http('openMall/getShareParamsCache', {
  107. scene:this.scene,
  108. },'GET').then(res => {
  109. var data= JSON.parse(res.data) ;
  110. console.log(data)
  111. this.id=data.couponId;
  112. this.getData();
  113. })
  114. },
  115. receive(id){
  116. uni.showLoading({
  117. title: '领取中'
  118. })
  119. this.$http('opencoupon/getCoupons', {
  120. id: this.id,
  121. }, 'GET').then(res => {
  122. /* uni.hideLoading();
  123. uni.showToast({
  124. title: '领取成功',
  125. icon:'none',
  126. duration: 3000
  127. }); */
  128. if(res.code==0){
  129. uni.showToast({
  130. title: '领取成功',
  131. icon:'none',
  132. duration: 3000
  133. });
  134. }
  135. //this.getData();
  136. })
  137. },
  138. getData() {
  139. uni.showLoading({
  140. title: '加载中'
  141. });
  142. if(this.type==2){
  143. var url='opencoupon/detailsCouponDetails';
  144. var params={
  145. id: this.id,
  146. custId:this.$store.state.wxOpenData.loginInfo.customerInfo.id
  147. }
  148. }else{
  149. var url='opencoupon/detailsCouponDetails'
  150. var params={
  151. id: this.id,
  152. }
  153. }
  154. this.$http(url, params, 'GET').then(res => {
  155. uni.hideLoading();
  156. this.detail = res.data;
  157. })
  158. },
  159. decryptPhoneNumber: function(e) {
  160. console.log(e);
  161. this.code=e.detail.code
  162. this.wxPhoneLogin()
  163. this.authorizShow=false;
  164. },
  165. wxPhoneLogin(){
  166. var that=this;
  167. this.$http('miniApp2/sys/wxPhoneLogin', {
  168. appId:this.ext.appId,
  169. unionId:this.ext.unionId,
  170. code:this.code,
  171. openId:this.wxOpenData.openid
  172. },'POST').then(res => {
  173. var data = res.data;
  174. if(data.loginInfo){
  175. this.userInfo=data.loginInfo.openUser;
  176. this.wxOpenData=data.loginInfo;
  177. this.$store.commit('mutationswxOpenData', data)
  178. this.$store.commit('mutationsuserInfo', this.userInfo)
  179. this.getData()
  180. }
  181. })
  182. },
  183. }
  184. }
  185. </script>
  186. <style scoped>
  187. .bottomBtn{
  188. width:704rpx;
  189. line-height: 88rpx;
  190. font-size: 30rpx;
  191. font-weight: 500;
  192. text-align: center;
  193. color: #FFFFFF;
  194. margin: 0 auto;
  195. margin-top: 80rpx;
  196. border-radius: 44rpx;
  197. }
  198. .boxtop{
  199. background: #FF0000;
  200. }
  201. .box {
  202. min-height: 100vh;
  203. background: #F4F5F7;
  204. }
  205. .detailBg {
  206. margin: -100rpx 24rpx 0rpx;
  207. background-color: #FFFFFF;
  208. border-radius: 10rpx;
  209. padding: 40rpx 20rpx;
  210. }
  211. .detailTop {
  212. display: flex;
  213. justify-content: flex-start;
  214. }
  215. .use {
  216. font-size: 26rpx;
  217. color: #FF0000;
  218. }
  219. .use2 {
  220. font-size: 40rpx;
  221. font-weight: 500;
  222. color: #FF0000;
  223. line-height: 56rpx;
  224. }
  225. .used {
  226. font-size: 26rpx;
  227. color: #666666;
  228. }
  229. .used2 {
  230. font-size: 40rpx;
  231. font-weight: 500;
  232. color: #666666;
  233. line-height: 56rpx;
  234. }
  235. .tiaojian {
  236. font-size: 24rpx;
  237. color: #666666;
  238. }
  239. .name {
  240. font-size: 30rpx;
  241. font-weight: 500;
  242. color: #333333;
  243. line-height: 56rpx;
  244. }
  245. .time {
  246. font-size: 24rpx;
  247. color: #666666;
  248. }
  249. .leftB {
  250. margin-right: 15rpx;
  251. }
  252. .comtentBox {
  253. margin: 20rpx 24rpx;
  254. background-color: #FFFFFF;
  255. border-radius: 10rpx;
  256. padding: 20rpx;
  257. }
  258. .titleBox {
  259. display: flex;
  260. align-items: center;
  261. }
  262. .redPoint {
  263. width: 18rpx;
  264. height: 18rpx;
  265. margin-right: 10rpx;
  266. }
  267. .title {
  268. font-size: 30rpx;
  269. color: #333333;
  270. font-weight: bold;
  271. }
  272. .content {
  273. font-size: 26rpx;
  274. color: #666666;
  275. margin-top: 16rpx;
  276. margin-left: 28rpx;
  277. }
  278. </style>