couponShare.vue 6.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300
  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>有效期:</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. }
  72. },
  73. onLoad(opt) {
  74. this.themeColor = uni.getStorageSync("themeColor");
  75. this.id = opt.id;
  76. this.type=opt.type;
  77. this.userInfo=this.$store.state.userInfo;
  78. this.ext=this.$common.getExtStoreId();
  79. if(this.userInfo){
  80. this.getData();
  81. }else{
  82. this.$common.automaticlogin().then(val => {
  83. this.userInfo=this.$store.state.userInfo;
  84. this.wxOpenData=this.$store.state.wxOpenData;
  85. this.getData();
  86. if(!this.userInfo){
  87. this.authorizShow=true
  88. }
  89. })
  90. }
  91. },
  92. methods: {
  93. receive(id){
  94. uni.showLoading({
  95. title: '领取中'
  96. })
  97. this.$http('opencoupon/getCoupons', {
  98. id: this.id,
  99. }, 'GET').then(res => {
  100. uni.hideLoading();
  101. uni.showToast({
  102. title: '领取成功',
  103. icon:'none',
  104. duration: 3000
  105. });
  106. this.getData();
  107. })
  108. },
  109. getData() {
  110. uni.showLoading({
  111. title: '加载中'
  112. });
  113. if(this.type==2){
  114. var url='opencoupon/detailsCouponDetails';
  115. var params={
  116. id: this.id,
  117. custId:this.$store.state.wxOpenData.loginInfo.customerInfo.id
  118. }
  119. }else{
  120. var url='opencoupon/detailsCoupon'
  121. var params={
  122. id: this.id,
  123. }
  124. }
  125. this.$http(url, params, 'GET').then(res => {
  126. uni.hideLoading();
  127. this.detail = res.data;
  128. })
  129. },
  130. decryptPhoneNumber: function(e) {
  131. console.log(e);
  132. this.code=e.detail.code
  133. this.wxPhoneLogin()
  134. this.authorizShow=false;
  135. },
  136. wxPhoneLogin(){
  137. var that=this;
  138. this.$http('miniApp2/sys/wxPhoneLogin', {
  139. appId:this.ext.appId,
  140. unionId:this.ext.unionId,
  141. code:this.code,
  142. openId:this.wxOpenData.openid
  143. },'POST').then(res => {
  144. var data = res.data;
  145. if(data.loginInfo){
  146. this.userInfo=data.loginInfo.openUser;
  147. this.wxOpenData=data.loginInfo;
  148. this.$store.commit('mutationswxOpenData', data)
  149. this.$store.commit('mutationsuserInfo', this.userInfo)
  150. this.getData()
  151. }
  152. })
  153. },
  154. }
  155. }
  156. </script>
  157. <style scoped>
  158. .bottomBtn{
  159. width:704rpx;
  160. line-height: 88rpx;
  161. font-size: 30rpx;
  162. font-weight: 500;
  163. text-align: center;
  164. color: #FFFFFF;
  165. margin: 0 auto;
  166. margin-top: 80rpx;
  167. border-radius: 44rpx;
  168. }
  169. .boxtop{
  170. background: #FF0000;
  171. }
  172. .box {
  173. min-height: 100vh;
  174. background: #F4F5F7;
  175. }
  176. .detailBg {
  177. margin: -100rpx 24rpx 0rpx;
  178. background-color: #FFFFFF;
  179. border-radius: 10rpx;
  180. padding: 40rpx 20rpx;
  181. }
  182. .detailTop {
  183. display: flex;
  184. justify-content: flex-start;
  185. }
  186. .use {
  187. font-size: 26rpx;
  188. color: #FF0000;
  189. }
  190. .use2 {
  191. font-size: 40rpx;
  192. font-weight: 500;
  193. color: #FF0000;
  194. line-height: 56rpx;
  195. }
  196. .used {
  197. font-size: 26rpx;
  198. color: #666666;
  199. }
  200. .used2 {
  201. font-size: 40rpx;
  202. font-weight: 500;
  203. color: #666666;
  204. line-height: 56rpx;
  205. }
  206. .tiaojian {
  207. font-size: 24rpx;
  208. color: #666666;
  209. }
  210. .name {
  211. font-size: 30rpx;
  212. font-weight: 500;
  213. color: #333333;
  214. line-height: 56rpx;
  215. }
  216. .time {
  217. font-size: 24rpx;
  218. color: #666666;
  219. }
  220. .leftB {
  221. margin-right: 15rpx;
  222. }
  223. .comtentBox {
  224. margin: 20rpx 24rpx;
  225. background-color: #FFFFFF;
  226. border-radius: 10rpx;
  227. padding: 20rpx;
  228. }
  229. .titleBox {
  230. display: flex;
  231. align-items: center;
  232. }
  233. .redPoint {
  234. width: 18rpx;
  235. height: 18rpx;
  236. margin-right: 10rpx;
  237. }
  238. .title {
  239. font-size: 30rpx;
  240. color: #333333;
  241. font-weight: bold;
  242. }
  243. .content {
  244. font-size: 26rpx;
  245. color: #666666;
  246. margin-top: 16rpx;
  247. margin-left: 28rpx;
  248. }
  249. </style>