zhaojs
2023-06-14 5c0484b788e699a8939579a14e7522afca5a5f34
no message
已修改4个文件
197 ■■■■ 文件已修改
uniapp/components/rowGoods.vue 16 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
uniapp/pages/login/bindingPhone.vue 133 ●●●● 补丁 | 查看 | 原始文档 | blame | 历史
uniapp/pages/login/wxlogin.vue 5 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
uniapp/uniCloud-aliyun/cloudfunctions/getPhoneNumber/index.js 43 ●●●●● 补丁 | 查看 | 原始文档 | blame | 历史
uniapp/components/rowGoods.vue
@@ -89,21 +89,27 @@
    
            .goodsnameinfo-content {
                width: 100%;
                position: relative;
                .typeIcon-content {
                    width: 60rpx;
                    height: 24rpx;
                    margin-right: 5rpx;
                    position: absolute;
                    top: 7rpx;
                }
    
                .tradename {
                    flex: 1;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    white-space: nowrap;
                    font-size: 28rpx;
                    font-weight: 500;
                    text-indent: 2.5em;
                    color: #333333;
                    text-overflow: -o-ellipsis-lastline;
                    overflow: hidden;
                    text-overflow: ellipsis;
                    display: -webkit-box;
                    -webkit-line-clamp: 2;
                    line-clamp: 2;
                    -webkit-box-orient: vertical;
                }
            }
    
uniapp/pages/login/bindingPhone.vue
@@ -5,28 +5,36 @@
            <view class="titleText">
                绑定手机号
            </view>
            <view class="input-container colCen">
                <view class="outSidebox rowCen" :class="selectedInput=='phone'?'outSidebox-active':''">
                    <input type="number" data-type='phone' @focus="changeType" @blur="cleanActive" v-model="phone"
                        placeholder="请输入手机号" placeholder-class="input-placeHolder" />
                </view>
            <view v-if="iscanbind" class="goaccount rowCenCen" @tap="mobShow()">
                <view>本机手机号一键绑定</view>
            </view>
            <view class="input-container colCen">
                <view class="outSidebox rowCenBet" data-type='pass'
                    :class="selectedInput=='code'?'outSidebox-active':''">
                    <input @focus="changeType" @blur="cleanActive" data-type='code' type="number" v-model="code"
                        placeholder="请输入验证码" placeholder-class="input-placeHolder" />
                    <view class="getcodebox" :class="canGetCode?'colorTxt':''" @click="getCode()">
                        {{canGetCode?'获取验证码':second+'s后重新获取'}}
            <view v-else>
                <view class="input-container colCen">
                    <view class="outSidebox rowCen" :class="selectedInput=='phone'?'outSidebox-active':''">
                        <input type="number" data-type='phone' @focus="changeType" @blur="cleanActive" v-model="phone"
                            placeholder="请输入手机号" placeholder-class="input-placeHolder" />
                    </view>
                </view>
            </view>
            <view class="login-btn rowCenCen" :class="code&&phone?'colorfulbtn':''" @click="bindMobile()">
                <view class="btn-font">
                    绑定
                <view class="input-container colCen">
                    <view class="outSidebox rowCenBet" data-type='pass'
                        :class="selectedInput=='code'?'outSidebox-active':''">
                        <input @focus="changeType" @blur="cleanActive" data-type='code' type="number" v-model="code"
                            placeholder="请输入验证码" placeholder-class="input-placeHolder" />
                        <view class="getcodebox" :class="canGetCode?'colorTxt':''" @click="getCode()">
                            {{canGetCode?'获取验证码':second+'s后重新获取'}}
                        </view>
                    </view>
                </view>
                <view class="login-btn rowCenCen" :class="code&&phone?'colorfulbtn':''" @click="bindMobile()">
                    <view class="btn-font">
                        绑定
                    </view>
                </view>
                <view style="text-align: center; width: 100%;margin-top: 30rpx;" @click="mobShow()">
                    本机手机号一键绑定
                </view>
            </view>
        </view>
@@ -51,6 +59,7 @@
    import MD5 from '../../utils/md5.js'
    import config from '../../utils/config.js'
    import utils from '../../utils/utils.js'
    const univerifyManager = uni.getUniverifyManager();
    export default {
        components: {
            inviteCodeModel,
@@ -72,7 +81,9 @@
                prevent: true,
                inviteCodeShow:false,
                inviterShow:false,
                wxUser:""
                wxUser:"",
                iscanbind:true,
                isyj:false
            };
        },
        onLoad(options) {
@@ -90,6 +101,76 @@
        },
        methods: {
            ...mapMutations(['login']),
            doMobileLogin(mobRes)
            {
                var that=this;
                uniCloud.callFunction({
                  name: 'getPhoneNumber', // 你的云函数名称
                  data: {
                    'access_token': mobRes.access_token, // 客户端一键登录接口返回的access_token
                    'openid': mobRes.openid, // 客户端一键登录接口返回的openid
                    'op_type':'getmob'
                  }
                }).then(res => {
                    console.log(res);
                    that.phone=res.result.mobile;
                    univerifyManager.close();
                    that.isyj=true;
                    that.bindMobile();
                }).catch(err=>{
                    // 处理错误
                    console.log(err)
                    that.iscanbind=false;
                    that.$alert('获取手机号码失败,请使用其他方式绑定')
                    setTimeout(function(){
                        univerifyManager.close();
                    },2000);
                })
            },
            mobShow()
            {
                var that=this;
                univerifyManager.login({
                    provider: 'univerify',
                    univerifyStyle: { // 自定义登录框样式
                    "fullScreen":false,
                    "authButton":
                    {
                        "normalColor":"#F73314",
                        "highlightColor":"#F73314",
                        "title":"本机号码一键绑定"
                    },
                    "otherLoginButton":{
                        "title":"其他绑定方式"
                    },
                    "privacyTerms":{
                        "defaultCheckBoxState":false
                    }
                  },
                success(res){ // 获取成功
                    console.log(res.authResult);
                     that.doMobileLogin(res.authResult);
                },
                fail(res){  // 登录失败
                    console.log(res)
                        if(res.errCode==30002)
                        {//切换登录方式
                            that.iscanbind=false;
                            univerifyManager.close();
                        }
                        else
                        {
                            that.$alert('获取手机号码失败,请使用其他方式绑定')
                            setTimeout(function(){
                                univerifyManager.close();
                            },2000);
                        }
                        that.iscanbind=false;
                    }
                })
            },
            backHome() {
                var pages = getCurrentPages();
                console.log(pages.length);
@@ -136,7 +217,8 @@
                    this.$u.api.bindMobileLogin({
                        wxUser : encodeURIComponent(JSON.stringify(that.wxUser)),
                        mobile:this.phone,
                        captcha:this.code
                        captcha:this.code,
                        isyj:this.isyj
                    }).then(e => {
                        console.log(e)
                        if (e.code != 0) return that.$alert(e.msg)
@@ -284,6 +366,17 @@
</script>
<style lang="scss">
    .goaccount {
        width: 100%;
        height: 100rpx;
        background: #FFFFFF;
        border: 1rpx solid #999999;
        border-radius: 50rpx;
        font-size: 30rpx;
        font-weight: 500;
        color: #333333;
        margin-top: 30rpx;
    }
    .login-wrapper {
        width: 100%;
        min-height: 100vh;
uniapp/pages/login/wxlogin.vue
@@ -148,6 +148,9 @@
                        {
                            "normalColor":"#F73314",
                            "highlightColor":"#F73314"
                        },
                        "privacyTerms":{
                            "defaultCheckBoxState":false
                        }
                        
                      },
@@ -160,6 +163,7 @@
                            if(res.errCode==30002)
                            {//切换登录方式
                                that.isother=true;
                                univerifyManager.close();
                            }
                            else
                            {
@@ -168,6 +172,7 @@
                                    univerifyManager.close();
                                },2000);
                            }
                            that.isother=true;
                        }
                    })
uniapp/uniCloud-aliyun/cloudfunctions/getPhoneNumber/index.js
@@ -16,20 +16,31 @@
              msg:'获取手机号失败'
          }
      }
      var apiUrl='http://dfgapp.ushopvip.com/api/user/mobilelogin';
      const apiRes = await uniCloud.httpclient.request(apiUrl, {
          method: 'POST',
          data: {
            mobile: res.phoneNumber,
            captcha:'000',
            ismobouth:true
          },
          contentType: 'json', // 指定以application/json发送data内的数据
          dataType: 'json' // 指定返回值为json格式,自动进行parse
        })
      //console.log(res); // res里包含手机号
      // 执行用户信息入库等操作,正常情况下不要把完整手机号返回给前端
      // 如果数据库在uniCloud上,可以直接入库
      // 如果数据库不在uniCloud上,可以通过 uniCloud.httpclient API,将手机号通过http方式传递给其他服务器的接口,详见:https://uniapp.dcloud.net.cn/uniCloud/cf-functions?id=httpclient
      return apiRes
      if(event.op_type=='getmob')
      {//获取手机号
          return {
              code:0,
              mobile:res.phoneNumber
          }
      }
      else
      {//手机号一键登录
          var apiUrl='http://dfgapp.ushopvip.com/api/user/mobilelogin';
          const apiRes = await uniCloud.httpclient.request(apiUrl, {
              method: 'POST',
              data: {
                mobile: res.phoneNumber,
                      captcha:'000',
                      ismobouth:true
              },
              contentType: 'json', // 指定以application/json发送data内的数据
              dataType: 'json' // 指定返回值为json格式,自动进行parse
            })
          //console.log(res); // res里包含手机号
          // 执行用户信息入库等操作,正常情况下不要把完整手机号返回给前端
          // 如果数据库在uniCloud上,可以直接入库
          // 如果数据库不在uniCloud上,可以通过 uniCloud.httpclient API,将手机号通过http方式传递给其他服务器的接口,详见:https://uniapp.dcloud.net.cn/uniCloud/cf-functions?id=httpclient
          return apiRes
      }
};