zhanghui преди 4 месеца
родител
ревизия
7d159c8611
променени са 4 файла, в които са добавени 468 реда и са изтрити 36 реда
  1. 32 30
      App.vue
  2. 9 0
      common/js/api.js
  3. 130 5
      pages/index/index.rpx.css
  4. 297 1
      pages/index/index.vue

+ 32 - 30
App.vue

@@ -37,40 +37,42 @@
                         let expandParam = uni.getStorageSync('expandParam')
                         if (expandParam) {
 
+
                             console.log('获取到的拓客端参数',expandParam)
                             if (new Date().getTime() <= expandParam.timestamp){
-
                                 if (isNew){
+                                  //登录成功,且是新用户,触发首页的自定义事件
+                                  uni.$emit("loginSuccess")
                                     //用户扫码拓客端进入小程序
-                                    that.$api.userBindMember(
-                                        {
-                                            ...expandParam,
-                                            memberId: res.data.data.userInfo.id
-                                        }
-                                    ).then(res1 => {
-                                        console.log('拓客端推广用户绑定成功!')
-
-                                        that.$api.addRecordForAttach({
-                                            ...expandParam,
-                                            isNew:1,
-                                            isBindSuccess:1,
-                                        }).then(res=>{
-                                            console.log('+++++++++新用户,扫码推广成功记录!++++++++++++++++')
-                                        })
-
-                                        uni.removeStorageSync('expandParam');
-                                    }).catch(err=>{
-
-                                        that.$api.addRecordForAttach({
-                                            ...expandParam,
-                                            isNew:1,
-                                            isBindSuccess:0,
-                                        }).then(res=>{
-                                            console.log('+++++++++新用户,扫码推广失败记录!++++++++++++++++')
-                                        })
-
-                                        uni.removeStorageSync('expandParam');
-                                    })
+                                    // that.$api.userBindMember(
+                                    //     {
+                                    //         ...expandParam,
+                                    //         memberId: res.data.data.userInfo.id
+                                    //     }
+                                    // ).then(res1 => {
+                                    //     console.log('拓客端推广用户绑定成功!')
+                                    //
+                                    //     that.$api.addRecordForAttach({
+                                    //         ...expandParam,
+                                    //         isNew:1,
+                                    //         isBindSuccess:1,
+                                    //     }).then(res=>{
+                                    //         console.log('+++++++++新用户,扫码推广成功记录!++++++++++++++++')
+                                    //     })
+                                    //
+                                    //     uni.removeStorageSync('expandParam');
+                                    // }).catch(err=>{
+                                    //
+                                    //     that.$api.addRecordForAttach({
+                                    //         ...expandParam,
+                                    //         isNew:1,
+                                    //         isBindSuccess:0,
+                                    //     }).then(res=>{
+                                    //         console.log('+++++++++新用户,扫码推广失败记录!++++++++++++++++')
+                                    //     })
+                                    //
+                                    //     uni.removeStorageSync('expandParam');
+                                    // })
                                 }else {
 
                                     that.$api.addRecordForAttach({

+ 9 - 0
common/js/api.js

@@ -3,6 +3,15 @@ import request from '../js/request.js';
 
 export default {
 
+    //根据拓客规则id查询规则
+    getRuleById(data) {
+        return request({
+            url: '/member/wechat/getRuleById',
+            method: 'POST',
+            data: data
+        })
+    },
+
     //查询未读的亲情卡消费记录
     getRecommendActivity(data) {
         return request({

+ 130 - 5
pages/index/index.rpx.css

@@ -1,7 +1,132 @@
-.tabBarLineHeight{
-    height: 138rpx;
+
+.expirePopup{
+    background: #f9f9f9;
+    border-radius: 16rpx;
+    padding: 32rpx;
+    width: 600rpx;
 }
-.tabBarView{
-    position: fixed;
-    bottom: 0;
+
+.popupTitle{
+    font-size: 30rpx;
+    font-weight: bold;
+    color: #333333;
+}
+.scroll-y1{
+    height: 800rpx;
+}
+
+
+
+.row-list{
+    width: 580rpx;
+    height: 188rpx;
+    margin-top: 24rpx;
+    background-image: url('/static/coupon/u210.png');
+    background-repeat: no-repeat;
+    background-size: cover;
+}
+
+.listBackground{
+    width: 580rpx;
+    height: 188rpx;
+    margin-top: 24rpx;
+    background-image: url('/static/coupon/u211.png');
+    background-repeat: no-repeat;
+    background-size: cover;
+}
+
+.h-text{
+    width: 200rpx;
+    height: 188rpx;
+}
+.h-center-content{
+    height: 188rpx;
+}
+.quan{
+    position: relative;
+}
+.h-right-content{
+    width: 160rpx;
+    height: 188rpx;
+    position: absolute;
+    top: 0;
+    right: 0;
+}
+.money{
+    height: 52rpx;
+    font-size: 36rpx;
+    font-family: DINAlternate-Bold, DINAlternate;
+    font-weight: bold;
+    color: #333333;
+    line-height: 52rpx;
+    text-align: center;
+}
+.desc{
+    height: 36rpx;
+    font-size: 20rpx;
+    font-family: PingFangSC-Regular, PingFang SC;
+    font-weight: 400;
+    color: #333333;
+    line-height: 36rpx;
+    text-align: center;
+}
+.h-value{
+    font-size: 28rpx;
+    font-family: PingFangSC-Medium, PingFang SC;
+    font-weight: bold;
+    color: #333333;
+    line-height: 44rpx;
+    margin-top: 24rpx;
+    margin-left: 24rpx;
+}
+.title{
+    font-size: 24rpx;
+    font-family: PingFangSC-Regular, PingFang SC;
+    font-weight: 400;
+    color: #999999;
+    line-height: 36rpx;
+    margin-left: 24rpx;
+
+}
+.h-btn-value-use{
+    width: 156rpx;
+    height: 64rpx;
+    background: #93D21A;
+    border-radius: 32rpx;
+
+    font-size: 24rpx;
+    font-family: PingFangSC-Regular, PingFang SC;
+    font-weight: 400;
+    color: #FFFFFF;
+    line-height: 64rpx;
+    text-align: center;
+}
+.h-btn-img{
+    width: 136rpx;
+    height: 136rpx;
+}
+.remark{
+    width: 646rpx;
+    padding: 20rpx;
+    font-size: 25rpx;
+    line-height: 40rpx;
+    background: #FFFFFF;
+    border-radius: 20rpx;
+    text-indent: 2em;
+    color: #999999;
+}
+
+.op-btn-wrap {
+    margin-top: 30px;
+    display: flex;
+    justify-content: center;
+    align-items: center;
+}
+.h-btn {
+    text-align: center;
+    width: 343px;
+    height: 42px;
+    background: #FFE05C;
+    border-radius: 27px;
+    line-height: 42px;
 }

+ 297 - 1
pages/index/index.vue

@@ -235,6 +235,136 @@
     <!--    <view class="tabBarView">-->
     <!--      <tab-bar :tabIndex="tabIndex"></tab-bar>-->
     <!--    </view>-->
+
+
+    <uni-popup ref="strategyListPoup">
+
+      <view class="flex-col justify-start expirePopup" >
+        <view class="flex-row justify-center">
+          <text class="popupTitle">新人专享</text>
+        </view>
+
+        <scroll-view scroll-y class="flex-col justify-start scroll-y1">
+          <view class="flex-col">
+
+            <u--form
+                labelPosition="left"
+                :model="phoneParam"
+                :rules="rules"
+                ref="form1"
+            >
+              <u-form-item
+                  label="手机号"
+                  prop="phonenumber"
+                  labelWidth="auto"
+                  labelAlign="right"
+              >
+                <u--input
+                    v-model="phoneParam.phonenumber"
+                    placeholder="请输入手机号"
+                    border="bottom"
+                    type="number"
+                    maxlength="11"
+                ></u--input>
+              </u-form-item>
+              <u-form-item
+                  labelWidth="auto"
+                  labelAlign="right"
+                  label="验证码"
+                  prop="smsCode"
+                  width="120"
+              >
+                <u--input
+                    v-model="phoneParam.smsCode"
+                    disabledColor="#ffffff"
+                    placeholder="请输入验证码"
+                    border="bottom"
+                    maxlength="4"
+                ></u--input>
+                <template #right>
+                  <view class="identifying-code">
+                    <u-code
+                        ref="uCode3"
+                        @change="codeChange2"
+                        keep-running
+                        start-text="获取验证码"
+                    ></u-code>
+                    <text
+                        @tap="getCode2"
+                        :text="tips2"
+                        class="u-page__code-text"
+                    >{{ tips2 }}
+                    </text>
+                  </view>
+                </template>
+
+              </u-form-item>
+            </u--form>
+
+            <view class="flex-col justify-start">
+              <text style="font-size: 28rpx;color: #333333;text-align: center">{{rule.title}}</text>
+
+            </view>
+
+            <view  class="flex-col " v-for="(item,index) in rule.strategyList" :key="index" >
+              <view class="flex-row justify-start quan "  :class="[item.select == 1 ? 'row-list' : 'listBackground']" @click="selectQuan(item,index)">
+                <view class="  h-text flex-col justify-center ">
+                  <view class="money">
+                    <text class="money" v-if="item.discountsType == 2">{{item.discount}}折</text>
+                    <text class="money" v-else>{{`减` + item.discountsPrice}}</text>
+                  </view>
+                  <view class="desc">
+                    <text>满{{item.reachPrice}}可用</text>
+                  </view>
+                </view>
+
+                <view class="  h-center-content flex-col justify-around">
+                  <view class="h-value">
+                    <text>{{item.name}}</text>
+                  </view>
+                  <view>
+                    <view class="title">
+                      可用次数:{{item.degree}}
+                    </view>
+                  </view>
+
+                  <view class="title flex-row">
+                    <text @click="showRemark(item)">使用说明</text>
+                    <u-icon v-if="item.id == showRemarkId" name="arrow-down-fill" color="" size="12"></u-icon>
+                    <u-icon v-else name="play-right-fill" color="" size="12"></u-icon>
+                  </view>
+                </view>
+              </view>
+              <view v-if="showRemarkId == item.id" class="remark"  style="text-indent:unset">
+                <view  class="remarkText">
+                  <view>
+                    可用门店:<text>{{item.useStoreDesc}}</text>
+                  </view>
+                  <view>
+                    适用项目:<text>{{item.useServiceDesc}}</text>
+                  </view>
+                  <view v-if="item.remark !=null">
+                    使用说明:<text>{{item.remark}}</text>
+                  </view>
+                  <text v-else class="remarkText">该优惠券暂无使用说明</text>
+                </view>
+              </view>
+            </view>
+          </view>
+        </scroll-view>
+
+        <view @click="userBindMember" class="op-btn-wrap">
+          <view class="h-btn">
+            <text v-if="rule.isAllReceived == 1">全部领取</text>
+            <text v-else>确定 (可选{{rule.receivedCount}}张优惠券)</text>
+          </view>
+        </view>
+
+      </view>
+
+    </uni-popup>
+
+
   </view>
 
 </template>
@@ -250,6 +380,7 @@ export default {
   },
   data() {
     return {
+
       isGetAddress: true, //是否获取到了经纬度
       noticeList: [],
       notice: '',
@@ -264,6 +395,43 @@ export default {
       },
       storeList: [],
       storeInfo: {},
+
+      showRemarkId:'',
+      rule:[],
+      tips2: '',
+
+      phoneParam: {
+        phonenumber: '',
+        smsCode: '',
+      },
+      rules: {
+        phonenumber: [
+          {
+            required: true,
+            min: 11,
+            max: 11,
+            message: '请输入11位电话号码',
+            trigger: ['blur', 'change'],
+          },
+          {
+            // 此为同步验证,可以直接返回true或者false,如果是异步验证,稍微不同,见下方说明
+            validator: (rule, value, callback) => {
+              // 调用uView自带的js验证规则,详见:https://www.uviewui.com/js/test.html
+              return !this.$isDataEmpty(value);
+            },
+            message: "请认真填写电话号码",
+            trigger: ['blur', 'change'],
+          }
+        ],
+        smsCode: {
+          required: true,
+          min: 4,
+          max: 6,
+          message: '请输入4位验证码',
+          trigger: ['blur', 'change'],
+        },
+      },
+
     };
   },
 
@@ -291,13 +459,17 @@ export default {
     }
   },
   onLoad(e) {
+
+    //程序启动时自动登录成功时触发的事件
+    uni.$off('loginSuccess')
+    uni.$on('loginSuccess',this.getRuleById)
+
     console.log(e)
     if (e.shareUserId) {
       //用户点击分享到好友或者朋友圈传递过来的参数
       uni.setStorageSync('shareUserId', e.shareUserId)
     }
 
-
     if (e.q) {
       //用户扫技师端或者拓客端二维码传递过来的参数
 
@@ -387,6 +559,127 @@ export default {
 
 
   methods: {
+
+
+    userBindMember (){
+      let expandParam = uni.getStorageSync('expandParam')
+      let that = this
+      this.$refs.form1.validate().then(res => {
+        let couponIds = []
+        for (const strategy of this.rule.strategyList) {
+          if (strategy.select == 1){
+            couponIds.push(strategy.id)
+          }
+        }
+
+      //用户扫码拓客端进入小程序
+      that.$api.userBindMember(
+          {
+            ...expandParam,
+            memberId: this.userInfo.id,
+            memberPhone:this.phoneParam.phonenumber,
+            code:this.phoneParam.code,
+            couponIds: couponIds
+          }
+      ).then(res1 => {
+        console.log('拓客端推广用户绑定成功!')
+
+        that.$api.addRecordForAttach({
+          ...expandParam,
+          isNew:1,
+          isBindSuccess:1,
+        }).then(res=>{
+          console.log('+++++++++新用户,扫码推广成功记录!++++++++++++++++')
+        })
+
+        uni.removeStorageSync('expandParam');
+      }).catch(err=>{
+
+        that.$api.addRecordForAttach({
+          ...expandParam,
+          isNew:1,
+          isBindSuccess:0,
+        }).then(res=>{
+          console.log('+++++++++新用户,扫码推广失败记录!++++++++++++++++')
+        })
+
+        uni.removeStorageSync('expandParam');
+      })
+
+      }).catch(errors => {
+        console.log(errors)
+        uni.$u.toast('校验失败,请认真填写')
+      })
+    },
+
+    codeChange2(text) {
+      this.tips2 = text;
+    },
+    getCode2() {
+      let that = this;
+      if (this.$refs.uCode3.canGetCode) {
+        that.getPhoneCode();
+      } else {
+        uni.$u.toast('倒计时结束后再发送');
+      }
+    },
+
+    // 获取验证码
+    getPhoneCode() {
+      let that = this;
+      // 模拟向后端请求验证码
+      uni.showLoading({
+        title: '正在获取验证码'
+      })
+      this.$api.getSmsCodeByType({phonenumber: this.phoneParam.phonenumber, auth: true, type: 0}).then((res) => {
+        uni.hideLoading();
+        // 这里此提示会被this.start()方法中的提示覆盖
+        uni.$u.toast('验证码已发送');
+        // 通知验证码组件内部开始倒计时
+        that.$refs.uCode3.start();
+      })
+    },
+
+
+    showRemark(item){
+      if (this.showRemarkId == item.id ){
+        this.showRemarkId = ''
+
+      }else {
+        this.showRemarkId = item.id
+
+      }
+    },
+
+    getRuleById(){
+      let expandParam = uni.getStorageSync('expandParam')
+      this.$api.getRuleById({
+        id: expandParam.ruleId
+      }).then(res=>{
+        this.rule  = res.data.data
+
+        if (this.rule.strategyList.length > 0){
+          for (const strategy of this.rule.strategyList) {
+              if (this.rule.isAllReceived == 1){
+                strategy.select = 1
+              }else {
+                strategy.select = 0
+              }
+          }
+          this.$refs.strategyListPoup.open()
+        }
+      })
+    },
+
+    selectQuan(item,index){
+      if (this.rule.isAllReceived == 1){
+        return
+      }
+      console.log(item)
+      item.select = item.select ? 0 : 1
+      this.$set(this.rule.strategyList,index,item)
+    },
+
     operLog() {
       let param = uni.getStorageSync('promotionParam')
       let userInfo = uni.getStorageSync('userInfo')
@@ -635,6 +928,9 @@ export default {
 </script>
 
 <style scoped lang="scss">
+
+@import "index.rpx.css";
+
 /* 头部内容 */
 .head-wrap {
   height: 100vh;