Browse Source

登录方式重构

master
Aaron 4 years ago
parent
commit
b196b5237d
  1. 7
      api/user.js
  2. 1
      components/CountDown.vue
  3. 26
      manifest.json
  4. 8
      pages/activity/DargainDetails/index.vue
  5. 6
      pages/activity/GoodsSeckill/index.vue
  6. 15
      pages/activity/GroupRule/index.vue
  7. 15
      pages/activity/Poster/index.vue
  8. 84
      pages/authorization/index.vue
  9. 87
      pages/home/index.vue
  10. 55
      pages/order/OrderDetails/index.vue
  11. 8
      pages/orderAdmin/AdminOrderList/index.vue
  12. 49
      pages/shop/EvaluateList/index.vue
  13. 121
      pages/shop/GoodsList/index.vue
  14. 118
      pages/user/Login/index.vue
  15. 343
      pages/user/Login/login.vue
  16. 4
      pages/user/PersonalData/index.vue
  17. 180
      pages/user/User/index.vue
  18. 19
      pages/user/coupon/GetCoupon/index.vue
  19. 4
      pages/user/signIn/Sign/index.vue
  20. 14
      utils/index.js
  21. 17
      utils/request.js

7
api/user.js

@ -403,6 +403,13 @@ export function wxappBindingPhone(data) {
return request.post('wxapp/binding', data)
}
/**
* 小程序上传用户头像
*/
export function wxappGetUserInfo (data) {
return request.post('/wxapp/loginAuth', data)
}
/*
* h5切换公众号登陆
* */

1
components/CountDown.vue

@ -85,7 +85,6 @@ export default {
runTime() {
//
let intDiff = this.time - Date.parse(new Date()) / 1000 //
console.log(intDiff)
let day = 0,
hour = 0,
minute = 0,

26
manifest.json

@ -135,7 +135,9 @@
"mp-weixin" : {
"appid" : "wx604d2ea4702620d2",
"setting" : {
"urlCheck" : false
"urlCheck" : true,
"postcss" : true,
"minified" : false
},
"usingComponents" : true,
"permission" : {
@ -165,17 +167,17 @@
"title" : "yshop",
"devServer" : {
"disableHostCheck" : true,
"proxy": {
"/h5api": {
//
"target": "http://itxzz.top",
"changeOrigin": true,
"secure": false,
"pathRewrite": {
"^/h5api": "/api"
}
}
}
"proxy" : {
"/h5api" : {
//
"target" : "http://itxzz.51vip.biz/",
"changeOrigin" : true,
"secure" : false,
"pathRewrite" : {
"^/h5api" : "/api"
}
}
}
},
"router" : {
"mode" : "history"

8
pages/activity/DargainDetails/index.vue

@ -38,8 +38,8 @@
<text class="num" v-text="bargainHelpCount.remainingPrice"></text>
</view>
<view class="acea-row row-middle">
<view class="successNum" v-text="'原价' + goodsDetail.price"></view>
<view class="successNum" v-text="'已有' + bargainSumCount + '人砍价成功'"></view>
<view class="successNum" v-text="`原价:${goodsDetail.price || 0}`"></view>
<view class="successNum" v-text="`已有${bargainSumCount || 0}人砍价成功`"></view>
</view>
</view>
</view>
@ -51,9 +51,9 @@
<!-- 砍价进度条下的金额 -->
<view class="balance acea-row row-between-wrapper">
<view v-text="'已砍' + bargainHelpCount.alreadyPrice + '元'"></view>
<view v-text="`已砍${bargainHelpCount.alreadyPrice || 0}元`"></view>
<view v-if="bargainHelpCount.price === 0">砍价成功</view>
<view v-else v-text="'还剩' + bargainHelpCount.price + '元'"></view>
<view v-else v-text="`还剩${bargainHelpCount.price || 0}元`"></view>
</view>
<!-- 砍价成功-->

6
pages/activity/GoodsSeckill/index.vue

@ -213,7 +213,10 @@ export default {
height: 210rpx;
position: fixed;
left: 0;
top: 0;
/* #ifdef H5 */
top: 80rpx;
/* #endif */
z-index: 1;
}
@ -222,7 +225,10 @@ export default {
height: 120rpx;
position: fixed;
left: 0;
top: 0;
/* #ifdef H5 */
top: 80rpx;
/* #endif */
z-index: 3;
overflow: hidden;
}

15
pages/activity/GroupRule/index.vue

@ -7,11 +7,11 @@
<view class="tui-price__box">
<view class="tui-goods-price">
<view class="tui-size-24"></view>
<view class="tui-price-large">{{ storeCombination.price.split('.')[0] }}</view>
<view class="tui-size-24">.{{ storeCombination.price.split('.')[1] }}</view>
<view class="tui-price-large">{{ storeCombination.price.split('.')[0] || 0 }}</view>
<view class="tui-size-24">.{{ storeCombination.price.split('.')[1] || 0 }}</view>
<!-- <text>已拼2020件</text> -->
</view>
<view class="tui-price-tag">{{ storeCombination.people }}人团</view>
<view class="tui-price-tag">{{ storeCombination.people || 0 }}人团</view>
</view>
</view>
</view>
@ -96,15 +96,14 @@ export default {
}
},
},
mounted: function() {
var that = this
mounted() {
let url = handleQrCode()
if (url) {
that.pinkId = url.pinkId
this.pinkId = url.pinkId
} else {
that.pinkId = that.$yroute.query.id
this.pinkId = this.$yroute.query.id
}
that.getCombinationPink()
this.getCombinationPink()
},
methods: {
pay: function() {

15
pages/activity/Poster/index.vue

@ -18,22 +18,21 @@
name: "Poster",
components: {},
props: {},
data: function () {
data () {
return {
status: true,
id: 0,
image: ""
};
},
mounted: function () {
var that = this;
var id = that.$yroute.query.id;
var type = that.$yroute.query.type;
that.id = id;
mounted () {
var id = this.$yroute.query.id;
var type = this.$yroute.query.type;
this.id = id;
if (type == 2) {
that.getBargainPoster();
this.getBargainPoster();
} else {
that.getCombinationPoster();
this.getCombinationPoster();
}
},
methods: {

84
pages/authorization/index.vue

@ -6,10 +6,12 @@
<view class="force-login__content y-f">
<open-data class="user-avatar" type="userAvatarUrl"></open-data>
<open-data class="user-name" type="userNickName"></open-data>
<view class="login-notice">为了提供更优质的服务需要获取您的头像昵称</view>
<button class="cu-btn author-btn" v-if="canIUseGetUserProfile" @tap="getUserInfoProfile">授权并查看</button>
<button class="cu-btn author-btn" v-else @getuserinfo="getUserInfo" open-type="getUserInfo">授权并查看</button>
<button class="cu-btn close-btn" @tap="back">暂不授权</button>
<view class="login-notice">为了提供更优质的服务请先登录</view>
<button
class="cu-btn author-btn"
open-type="getPhoneNumber"
@getphonenumber="phoneLogin">微信手机号一键登录</button>
<button class="cu-btn close-btn" @tap="back">暂不登录</button>
</view>
</view>
<!-- #endif -->
@ -27,10 +29,11 @@
<script>
import { mapState, mapMutations, mapActions } from 'vuex'
import { wxappAuth, getUser } from '@/api/user'
import { wxappAuth, getUser, getUserInfo } from '@/api/user'
import { login, authorize, getProvider } from '@/utils'
import dayjs from 'dayjs'
import cookie from '@/utils/store/cookie'
import { login, authorize } from '@/utils'
import store from '@/store'
export default {
data() {
@ -43,11 +46,8 @@ export default {
...mapState(['isAuthorization', '$deviceType', 'token']),
},
onLoad() {
console.log(wx.getUserProfile)
if (wx.getUserProfile) {
console.log(this)
this.canIUseGetUserProfile = true
console.log(this.canIUseGetUserProfile)
}
// //
},
@ -74,9 +74,9 @@ export default {
query: {},
})
},
getUserInfo(data) {
getUserInfoBtn(data) {
console.log(data)
console.log('getUserInfo')
console.log('getUserInfoBtn')
if (data.detail.errMsg == 'getUserInfo:fail auth deny') {
uni.showToast({
title: '取消授权',
@ -106,13 +106,14 @@ export default {
})
})
},
//
getUserInfoProfile(data) {
console.log('getUserInfoProfile')
wx.getUserProfile({
lang: 'zh_CN',
desc: '需要获取您的信息用来展示',
success: res => {
console.log(res)
console.log('用户信息',res)
uni.showLoading({
title: '登录中',
})
@ -134,10 +135,67 @@ export default {
},
})
},
//
phoneLogin(e) {
console.log('用户微信手机号登录')
if (e.mp.detail.errMsg == 'getPhoneNumber:ok') {
console.log(e.mp.detail)
getProvider()
.then(provider => {
console.log('当前的环境商',provider)
if (!provider) {
reject()
}
// uni
uni.login({
provider: provider,
success: async function(loginRes) {
console.log(loginRes)
let code = loginRes.code // code
cookie.set('wxLoginCode', loginRes.code)
wxappAuth({
encryptedData: e.mp.detail.encryptedData,
iv: e.mp.detail.iv,
code: code,
spread: cookie.get('spread'),
})
.then( res => {
console.log('登录成功,开始处理登录信息保存,并获取用户详情')
uni.hideLoading()
store.commit('login', res.data.token, dayjs(res.data.expires_time))
store.dispatch('userInfo', true)
getUserInfo()
.then(user => {
console.log('获取用户信息成功')
uni.setStorageSync('uid', user.data.uid)
store.dispatch('setUserInfo', user.data)
this.$yrouter.reLaunch({
path: cookie.get('redirect').replace(/\ /g, ''),
})
})
.catch(error => {
console.log('获取用户信息失败')
})
})
.catch(error => {
console.log(error)
console.log('登录接口调用失败')
})
}
})
})
.catch(err => {})
} else {
uni.showToast({
title: '已拒绝授权',
icon: 'none',
duration: 2000,
})
}
},
},
mounted() {
if (wx.getUserProfile) {
console.log(this)
this.canIUseGetUserProfile = true
console.log(this.canIUseGetUserProfile)
}

87
pages/home/index.vue

@ -19,36 +19,52 @@
</view>
<!-- #endif -->
</view>
<Banner v-if="item.type == 'banner'" :detail="item.componentContent.bannerData" @getbgcolor="getbgcolor"></Banner>
<uni-notice-bar v-if="item.type == 'noticeBar'" scrollable="true" @click="goRoll(item.componentContent.roll[0])" single="true" :speed="10" showIcon="true" :text="item.componentContent.roll[0].info"></uni-notice-bar>
<view class="content_box home_content_box" v-if="item.type == 'menu' && item.componentContent.menus">
<Banner v-if="item.type == 'banner'"
:detail="item.componentContent.bannerData"
@getbgcolor="getbgcolor"></Banner>
<uni-notice-bar
v-if="item.type == 'noticeBar'"
scrollable="true"
@click="goRoll(item.componentContent.roll[0])"
single="true" :speed="10"
showIcon="true"
:text="item.componentContent.roll[0].info"></uni-notice-bar>
<view class="content_box home_content_box"
v-if="item.type == 'menu' && item.componentContent.menus">
<!-- 菜单 -->
<Menu :list="item.componentContent.menus"></Menu>
</view>
<!-- 滚动新闻 -->
<!-- 广告 -->
<Adv v-if="item.type == 'adv' && item.componentContent.detail" :detail="item.componentContent.detail" />
<Adv v-if="item.type == 'adv' && item.componentContent.detail"
:detail="item.componentContent.detail" />
<!-- 热门榜单 -->
<HotCommodity v-if="item.type == 'hotCommodity'" :detail="likeInfo"></HotCommodity>
<HotCommodity v-if="item.type == 'hotCommodity'"
:detail="likeInfo" />
<!-- 超值拼团 -->
<Groupon v-if="item.type == 'groupon'" :detail="combinationList" />
<!-- 首发新品->秒杀 -->
<FirstNewProduct v-if="item.type == 'firstNewProduct'" :detail="firstList"></FirstNewProduct>
<FirstNewProduct v-if="item.type == 'firstNewProduct'"
:detail="firstList" />
<!-- 精品推荐 -->
<ProductsRecommended v-if="item.type == 'productsRecommended'" :detail="bastList"></ProductsRecommended>
<ProductsRecommended v-if="item.type == 'productsRecommended'"
:detail="bastList" />
<!-- 促销单品 -->
<PromoteProduct v-if="item.type == 'promoteProduct'" :detail="benefit"></PromoteProduct>
<PromoteProduct v-if="item.type == 'promoteProduct'"
:detail="benefit" />
<!-- 直播 -->
<!-- #ifdef MP-WEIXIN -->
<Live v-if="item.type == 'live'" :detail="live"></Live>
<Live v-if="item.type == 'live'" :detail="live" />
<!-- #endif -->
<!-- 为您推荐 -->
<PromotionGood v-if="item.type == 'promotionGood'" :benefit="benefit"></PromotionGood>
<Coupon-window :coupon-list="couponList" v-if="showCoupon" @checked="couponClose" @close="couponClose"> </Coupon-window>
<PromotionGood v-if="item.type == 'promotionGood'" :benefit="benefit" />
<Coupon-window
:coupon-list="couponList"
v-if="showCoupon"
@checked="couponClose" @close="couponClose" />
</view>
<!-- <view class="demo" style='height:100rpx'></view> -->
<!-- #ifndef APP-PLUS -->
<view class="bottomSpace" style='line-height:100rpx'>PC</view>
<!-- #ifdef H5 -->
<view class="bottomSpace" style='line-height:100rpx'>正在使用H5方式浏览</view>
<!-- #endif -->
</view>
</template>
@ -182,6 +198,7 @@ export default {
observeParents: true,
},
bgImage: '',
// indexTitle: false,
}
},
computed: {
@ -198,34 +215,40 @@ export default {
return style
},
},
onLoad: function() {
onLoad() {
this.getLocation()
let that = this
// uni.showLoading({
// title: "",
// });
getCanvas()
.then(res => {})
.then(res => {
console.log('223',res)
})
.catch(error => {
if (!error) {
return
}
this.homeData = JSON.parse(error.data.json)
console.log(this.homeData)
console.log(222)
console.log('225',this.homeData)
})
getHomeData().then(res => {
that.logoUrl = res.data.logoUrl
res.data.banner.map(item => (item.bgcolor = item.color || ''))
that.$set(that, 'info', res.data.info)
that.$set(that, 'firstList', res.data.firstList)
that.$set(that, 'bastList', res.data.bastList)
that.$set(that, 'likeInfo', res.data.likeInfo)
that.$set(that, 'live', res.data.liveList)
that.$set(that, 'lovely', res.data.lovely)
that.$set(that, 'benefit', res.data.benefit)
that.$set(that, 'couponList', res.data.couponList)
that.$set(that, 'combinationList', res.data.combinationList)
this.logoUrl = res.data.logoUrl
res.data.banner.forEach(item => (item.bgcolor = item.color || ''))
this.info = res.data.info
console.log('239', res.data.info)
console.log('239',this.info)
this.$set(this, 'info', res.data.info)
this.$set(this, 'firstList', res.data.firstList)
this.$set(this, 'bastList', res.data.bastList)
this.$set(this, 'likeInfo', res.data.likeInfo)
this.$set(this, 'live', res.data.liveList)
this.$set(this, 'lovely', res.data.lovely)
this.$set(this, 'benefit', res.data.benefit)
this.$set(this, 'couponList', res.data.couponList)
this.$set(this, 'combinationList', res.data.combinationList)
uni.hideLoading()
that.setOpenShare()
// that.doColorThief()
this.setOpenShare()
// this.doColorThief()
})
},
methods: {

55
pages/order/OrderDetails/index.vue

@ -4,7 +4,7 @@
<view class="header bg-color-red acea-row row-middle" :class="refundOrder ? 'on' : ''">
<view class="data" :class="refundOrder ? 'on' : ''">
<view class="state">{{ orderInfo._status._msg }}</view>
<view>{{ orderInfo.createTime }}</view>
<view>{{ orderInfo.createTime || '' }}</view>
</view>
</view>
<template v-if="!refundOrder">
@ -24,14 +24,18 @@
: 'icon-yuandianxiao',
status.type >= 0 ? 'font-color-red' : ''
]"></view>
<view class="line" :class="{ 'bg-color-red': status.type > 0 && status.type != 9 }"></view>
<view class="line" :class="{
'bg-color-red': status.type > 0 && status.type != 9
}"></view>
<view class="iconfont" :class="[
status.type === 1 ? 'icon-webicon318' : 'icon-yuandianxiao',
status.type >= 1 && status.type != 6 && status.type != 9
? 'font-color-red'
: ''
]"></view>
<view class="line" :class="{'bg-color-red':status.type > 1 && status.type != 6 && status.type != 9}"
<view class="line" :class="{
'bg-color-red':status.type > 1 && status.type != 6 && status.type != 9
}"
v-if="orderInfo.shippingType === 1"></view>
<view class="iconfont"
:class="[status.type === 2 ? 'icon-webicon318' : 'icon-yuandianxiao',status.type >= 2 && status.type != 6 && status.type != 9? 'font-color-red': '']"
@ -47,8 +51,7 @@
: ''
]"></view>
<view class="line" :class="{
'bg-color-red':
status.type > 3 && status.type != 6 && status.type != 9
'bg-color-red': status.type > 3 && status.type != 6 && status.type != 9
}"></view>
<view class="iconfont" :class="[
status.type == 4 ? 'icon-webicon318' : 'icon-yuandianxiao',
@ -105,8 +108,9 @@
<div class="name">
{{ system_store.name}}
<span class="phone">{{ system_store.phone }}</span>
<span @click="telPhone(system_store.phone)" class="iconfont icon-tonghua font-color-red"
:href="'tel:' + system_store.phone"></span>
<span @click="telPhone(system_store.phone)"
class="iconfont icon-tonghua font-color-red"
:href="'tel:' + system_store.phone"></span>
</div>
<div>{{ system_store.address }}</div>
</div>
@ -119,19 +123,19 @@
<view class="item acea-row row-between">
<view>订单编号</view>
<view class="conter acea-row row-middle row-right">
{{ orderInfo.orderId }}
<!-- #ifndef H5 -->
<text class="copy copy-data" @click="copyClipboard(orderInfo.orderId)">复制</text>
<!-- #endif -->
{{ orderInfo.orderId || '' }}
<!-- #ifndef H5 -->
<text class="copy copy-data" @click="copyClipboard(orderInfo.orderId)">复制</text>
<!-- #endif -->
</view>
</view>
<view class="item acea-row row-between">
<view>下单时间</view>
<view class="conter">{{ orderInfo.createTime }}</view>
<view class="conter">{{ orderInfo.createTime || '' }}</view>
</view>
<view class="item acea-row row-between">
<view>订单类型</view>
<view class="conter">{{ orderTypeName }}</view>
<view class="conter">{{ orderTypeName || '' }}</view>
</view>
<view class="item acea-row row-between">
<view>支付状态</view>
@ -139,11 +143,11 @@
</view>
<view class="item acea-row row-between">
<view>支付方式</view>
<view class="conter">{{ orderInfo._status._payType }}</view>
<view class="conter">{{ orderInfo._status._payType || '' }}</view>
</view>
<view class="item acea-row row-between" v-if="orderInfo.mark">
<view>买家留言</view>
<view class="conter">{{ orderInfo.mark }}</view>
<view class="conter">{{ orderInfo.mark || '' }}</view>
</view>
</view>
@ -185,42 +189,42 @@
<view class="wrapper" v-if="refundOrder">
<view class="item acea-row row-between">
<view>收货人</view>
<view class="conter">{{ orderInfo.realName }}</view>
<view class="conter">{{ orderInfo.realName || '' }}</view>
</view>
<view class="item acea-row row-between">
<view>联系电话</view>
<view class="conter">{{ orderInfo.userPhone }}</view>
<view class="conter">{{ orderInfo.userPhone || '' }}</view>
</view>
<view class="item acea-row row-between">
<view>收货地址</view>
<view class="conter">{{ orderInfo.userAddress }}</view>
<view class="conter">{{ orderInfo.userAddress || '' }}</view>
</view>
</view>
<view class="wrapper">
<view class="item acea-row row-between" v-if="!isIntegral">
<view>支付金额</view>
<view class="conter">{{ orderInfo.totalPrice }}</view>
<view class="conter">{{ orderInfo.totalPrice || 0 }}</view>
</view>
<view class="item acea-row row-between" v-if="isIntegral">
<view>支付积分</view>
<view class="conter">{{ orderInfo.payIntegral }}积分</view>
<view class="conter">{{ orderInfo.payIntegral || 0 }}积分</view>
</view>
<view class="item acea-row row-between" v-if="orderInfo.couponPrice > 0">
<view>优惠券抵扣</view>
<view class="conter">-{{ orderInfo.couponPrice }}</view>
<view class="conter">-{{ orderInfo.couponPrice ||0 }}</view>
</view>
<view class="item acea-row row-between" v-if="orderInfo.useIntegral > 0">
<view>积分抵扣</view>
<view class="conter">-{{ orderInfo.deductionPrice }}</view>
<view class="conter">-{{ orderInfo.deductionPrice || 0 }}</view>
</view>
<view class="item acea-row row-between" v-if="orderInfo.payPostage > 0">
<view>运费</view>
<view class="conter">{{ orderInfo.payPostage }}</view>
<view class="conter">{{ orderInfo.payPostage || 0 }}</view>
</view>
<view class="actualPay acea-row row-right">
实付款
<text class="money font-color-red" v-if="!isIntegral">{{ orderInfo.payPrice }}</text>
<text class="money font-color-red" v-if="isIntegral">{{ orderInfo.payIntegral }}积分</text>
<text class="money font-color-red" v-if="!isIntegral">{{ orderInfo.payPrice || 0 }}</text>
<text class="money font-color-red" v-if="isIntegral">{{ orderInfo.payIntegral || 0 }}积分</text>
</view>
</view>
<view style="height:100rpx;" v-if="!refundOrder && offlineStatus"></view>
@ -494,7 +498,6 @@
},
async toPay(type) {
var that = this;
console.log(type, "支付方式");
await payOrderHandle(this.orderInfo.orderId, type, that.from);
that.getDetail();
},

8
pages/orderAdmin/AdminOrderList/index.vue

@ -62,8 +62,12 @@
</view>
</view>
<Loading :loaded="loaded" :loading="loading"></Loading>
<PriceChange :change="change" :orderInfo="orderInfo" v-on:closechange="changeclose($event)" v-on:savePrice="savePrice"
:status="status"></PriceChange>
<PriceChange
:change="change"
:orderInfo="orderInfo"
v-on:closechange="changeclose($event)"
v-on:savePrice="savePrice"
:status="status"></PriceChange>
</view>
</template>
<script>

49
pages/shop/EvaluateList/index.vue

@ -72,37 +72,34 @@ export default {
!this.loading && this.getProductReplyList();
},
methods: {
getProductReplyCount: function() {
let that = this;
getReplyConfig(that.product_id).then(res => {
that.$set(that, "replyData", res.data);
that.navList[0].num = res.data.sumCount;
that.navList[1].num = res.data.goodCount;
that.navList[2].num = res.data.inCount;
that.navList[3].num = res.data.poorCount;
getProductReplyCount () {
getReplyConfig(this.product_id).then(res => {
this.$set(that, "replyData", res.data);
this.navList[0].num = res.data.sumCount;
this.navList[1].num = res.data.goodCount;
this.navList[2].num = res.data.inCount;
this.navList[3].num = res.data.poorCount;
});
},
getProductReplyList: function() {
let that = this;
if (that.loading) return; //false
if (that.loadend) return; //false
that.loading = true;
let q = { page: that.page, limit: that.limit, type: that.currentActive };
getReplyList(that.product_id, q).then(res => {
that.loading = false;
getProductReplyList () {
if (this.loading) return; //false
if (this.loadend) return; //false
this.loading = true;
let q = { page: this.page, limit: this.limit, type: this.currentActive };
getReplyList(this.product_id, q).then(res => {
this.loading = false;
//apply();js;
that.reply.push.apply(that.reply, res.data);
that.loadend = res.data.length < that.limit; //
that.page = that.page + 1;
this.reply.push.apply(this.reply, res.data);
this.loadend = res.data.length < this.limit; //
this.page = this.page + 1;
});
},
changeType: function(index) {
let that = this;
that.currentActive = index;
that.page = 1;
that.loadend = false;
that.$set(that, "reply", []);
that.getProductReplyList();
changeType (index) {
this.currentActive = index;
this.page = 1;
this.loadend = false;
this.$set(this, "reply", []);
this.getProductReplyList();
}
}
};

121
pages/shop/GoodsList/index.vue

@ -109,7 +109,7 @@ export default {
nows: false,
recommendLoading: false,
target: false,
isIntegral: false,
isIntegral: false
}
},
watch: {
@ -193,10 +193,11 @@ export default {
this.loading = false
if (this.target) {
this.productList = res.data
this.target = false
} else {
this.productList.push.apply(this.productList, res.data)
}
this.target = false
console.log(this.target)
this.loadend = res.data.length < this.where.limit //
this.where.page = this.where.page + 1
})
@ -209,60 +210,78 @@ export default {
this.getProductList()
},
//
set_where: function(index) {
let that = this
switch (index) {
case 0:
return that.$yrouter.push({
path: '/pages/shop/GoodsClass/index',
})
case 1:
if (that.price === 0) that.price = 1
else if (that.price === 1) that.price = 2
else if (that.price === 2) that.price = 0
that.stock = 0
break
case 2:
if (that.stock === 0) that.stock = 1
else if (that.stock === 1) that.stock = 2
else if (that.stock === 2) that.stock = 0
that.price = 0
break
case 3:
that.nows = !that.nows
break
default:
break
}
this.productList = []
that.$set(that, 'productList', [])
that.where.page = 1
that.target = true
that.loadend = false
that.getProductList()
set_where(index) {
this.productList = []
this.$set(this, 'productList', [])
this.where.page = 1
this.target = true
this.loadend = false
switch (index) {
case 0:
return this.$yrouter.push({
path: '/pages/shop/GoodsClass/index',
})
case 1:
if (this.price === 0) this.price = 1
else if (this.price === 1) this.price = 2
else if (this.price === 2) this.price = 0
this.stock = 0
break
case 2:
if (this.stock === 0) this.stock = 1
else if (this.stock === 1) this.stock = 2
else if (this.stock === 2) this.stock = 0
this.price = 0
break
case 3:
this.nows = !this.nows
break
default:
break
}
// this.getProductList()
this.setWhere()
const { s = '', id = 0, title = '' } = this.$yroute.query
if (s !== this.where.keyword || id !== this.where.sid) {
this.loadend = false
this.loading = false
this.where.page = 1
this.where.sid = id
this.title = title && id ? title : ''
this.nows = false
this.$set(this, 'productList', [])
this.price = 0
this.stock = 0
// this.getProductList();
}
let q = this.where
let getData = this.isIntegral !== 'true' ? getProducts : getProductsIntegral
getData(this.where).then(res => {
this.loading = false
this.productList = res.data
})
},
//where
setWhere: function() {
let that = this
if (that.price === 0) {
that.where.priceOrder = ''
} else if (that.price === 1) {
that.where.priceOrder = 'asc'
} else if (that.price === 2) {
that.where.priceOrder = 'desc'
setWhere() {
if (this.price === 0) {
this.where.priceOrder = ''
} else if (this.price === 1) {
this.where.priceOrder = 'asc'
} else if (this.price === 2) {
this.where.priceOrder = 'desc'
}
if (that.stock === 0) {
that.where.salesOrder = ''
} else if (that.stock === 1) {
that.where.salesOrder = 'asc'
} else if (that.stock === 2) {
that.where.salesOrder = 'desc'
if (this.stock === 0) {
this.where.salesOrder = ''
} else if (this.stock === 1) {
this.where.salesOrder = 'asc'
} else if (this.stock === 2) {
this.where.salesOrder = 'desc'
}
that.where.news = that.nows ? '1' : '0'
this.where.news = this.nows ? '1' : '0'
},
switchTap: function() {
let that = this
that.Switch = !that.Switch
switchTap() {
this.Switch = !this.Switch
},
},
}

118
pages/user/Login/index.vue

@ -1,7 +1,7 @@
<template>
<view class="register absolute">
<view class="whiteBg" v-if="formItem === 1">
<view class="title acea-row row-between-wrapper">
<view class="title acea-row">
<view class="item" :class="current === index ? 'on' : ''" v-for="(item, index) in navList"
@click="navTap(index)" :key="index">{{ item }}</view>
</view>
@ -9,42 +9,32 @@
<form @submit.prevent="submit">
<view class="item">
<view class="acea-row row-between-wrapper">
<!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-phone_" />
</svg>-->
<input type="text" placeholder="输入手机号码" v-model="account" required />
<input type="text" placeholder="输入手机号码"
v-model="account" required
@input="checkPhone"/>
</view>
</view>
<view class="item">
<view class="item" v-if="account.length === 11">
<view class="acea-row row-between-wrapper">
<!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-code_" />
</svg>-->
<input type="password" placeholder="填写登录密码" v-model="password" required />
</view>
</view>
</form>
</view>
<view class="list" :hidden="current !== 1">
<!-- <view class="list" :hidden="current !== 1">
<view class="item">
<view class="acea-row row-between-wrapper">
<!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-phone_" />
</svg>-->
<input type="text" placeholder="输入手机号码" v-model="account" />
</view>
</view>
<view class="item">
<view class="align-left">
<!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-code_1" />
</svg>-->
<input type="text" placeholder="填写验证码" class="codeIput" v-model="captcha" />
<button class="code" :disabled="disabled" :class="disabled === true ? 'on' : ''"
@click="code">{{ text }}</button>
</view>
</view>
</view>
</view> -->
<view class="logon" @click="loginMobile" :hidden="current !== 1">登录</view>
<view class="logon" @click="submit" :hidden="current === 1">登录</view>
<view class="tip">
@ -52,6 +42,7 @@
<text @click="formItem = 2" class="font-color-red">立即注册</text>
</view>
</view>
<!-- 注册 -->
<view class="whiteBg" v-else>
<view class="title acea-row row-between-wrapper">
<view class="item on">注册账号</view>
@ -133,7 +124,7 @@
mixins: [sendVerifyCode],
data: function () {
return {
navList: ["号登录"],
navList: ["手机号登录"],
current: 0,
account: "",
password: "",
@ -144,49 +135,54 @@
};
},
methods: {
async loginMobile() {
var that = this;
const {
account,
captcha
} = that;
try {
await that
.$validator({
account: [
required(required.message("手机号码")),
chs_phone(chs_phone.message())
],
captcha: [
required(required.message("验证码")),
alpha_num(alpha_num.message("验证码"))
]
})
.validate({
account,
captcha
});
} catch (e) {
return validatorDefaultCatch(e);
}
loginMobile({
phone: that.account,
captcha: that.captcha,
spread: cookie.get("spread")
})
.then(res => {
var data = res.data;
that.$store.commit("login", data.token, dayjs(data.expires_time));
handleGetUserInfo();
})
.catch(err => {
uni.showToast({
title: err.msg || err.response.data.msg || err.response.data.message,
icon: "none",
duration: 2000
});
});
},
checkPhone(e) {
if (e.target.value.length === 11) {
console.log('手机号')
}
},
async loginMobile() {
var that = this;
const {
account,
captcha
} = that;
try {
await that
.$validator({
account: [
required(required.message("手机号码")),
chs_phone(chs_phone.message())
],
captcha: [
required(required.message("验证码")),
alpha_num(alpha_num.message("验证码"))
]
})
.validate({
account,
captcha
});
} catch (e) {
return validatorDefaultCatch(e);
}
loginMobile({
phone: that.account,
captcha: that.captcha,
spread: cookie.get("spread")
})
.then(res => {
var data = res.data;
that.$store.commit("login", data.token, dayjs(data.expires_time));
handleGetUserInfo();
})
.catch(err => {
uni.showToast({
title: err.msg || err.response.data.msg || err.response.data.message,
icon: "none",
duration: 2000
});
});
},
async register() {
var that = this;
const {

343
pages/user/Login/login.vue

@ -0,0 +1,343 @@
<template>
<view class="register absolute">
<view class="whiteBg" v-if="formItem === 1">
<view class="title acea-row">
<view class="item" :class="current === index ? 'on' : ''" v-for="(item, index) in navList"
@click="navTap(index)" :key="index">{{ item }}</view>
</view>
<view class="list" :hidden="current !== 0">
<form @submit.prevent="submit">
<view class="item">
<view class="acea-row row-between-wrapper">
<!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-phone_" />
</svg>-->
<input type="text" placeholder="输入手机号码" v-model="account" required />
</view>
</view>
<view class="item">
<view class="acea-row row-between-wrapper">
<!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-code_" />
</svg>-->
<input type="password" placeholder="填写登录密码" v-model="password" required />
</view>
</view>
</form>
</view>
<view class="list" :hidden="current !== 1">
<view class="item">
<view class="acea-row row-between-wrapper">
<!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-phone_" />
</svg>-->
<input type="text" placeholder="输入手机号码" v-model="account" />
</view>
</view>
<view class="item">
<view class="align-left">
<!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-code_1" />
</svg>-->
<input type="text" placeholder="填写验证码" class="codeIput" v-model="captcha" />
<button class="code" :disabled="disabled" :class="disabled === true ? 'on' : ''"
@click="code">{{ text }}</button>
</view>
</view>
</view>
<view class="logon" @click="loginMobile" :hidden="current !== 1">登录</view>
<view class="logon" @click="submit" :hidden="current === 1">登录</view>
<view class="tip">
没有账号?
<text @click="formItem = 2" class="font-color-red">立即注册</text>
</view>
</view>
<!-- 注册 -->
<view class="whiteBg" v-else>
<view class="title acea-row row-between-wrapper">
<view class="item on">注册账号</view>
</view>
<view class="list">
<view class="item">
<view>
<!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-phone_" />
</svg>-->
<input name="account" type="text" placeholder="输入手机号码" v-model="account" />
</view>
</view>
<view class="item">
<view class="align-left">
<!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-code_1" />
</svg>-->
<input name="verifyCode" type="text" placeholder="填写验证码" class="codeIput" v-model="captcha" />
<button class="code" :disabled="disabled" :class="disabled === true ? 'on' : ''"
@click="code">{{ text }}</button>
</view>
</view>
<view class="item">
<view>
<!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-code_" />
</svg>-->
<input name="password" type="password" placeholder="填写您的登录密码" v-model="password" />
</view>
</view>
<!-- #ifndef H5 -->
<view class="item">
<view>
<!-- <svg class="icon" aria-hidden="true">
<use xlink:href="#icon-phone_" />
</svg>-->
<input name="inviteCode" type="text" placeholder="输入邀请码" v-model="inviteCode" />
</view>
</view>
<!-- #endif -->
</view>
<view class="logon" @click="register">注册</view>
<view class="tip">
已有账号?
<text @click="formItem = 1" class="font-color-red">立即登录</text>
</view>
</view>
</view>
</template>
<script>
import sendVerifyCode from "@/mixins/SendVerifyCode";
import {
login,
loginMobile,
registerVerify,
register
} from "@/api/user";
import attrs, {
required,
alpha_num,
chs_phone
} from "@/utils/validate";
import {
validatorDefaultCatch
} from "@/utils/dialog";
import dayjs from "dayjs";
import cookie from "@/utils/store/cookie";
import {
handleGetUserInfo
} from "@/utils";
const BACK_URL = "login_back_url";
export default {
name: "Login",
mixins: [sendVerifyCode],
data: function () {
return {
navList: ["账号登录", "修改密码"],
current: 0,
account: "",
password: "",
captcha: "",
inviteCode: "",
formItem: 1,
type: "login"
};
},
methods: {
async loginMobile() {
var that = this;
const {
account,
captcha
} = that;
try {
await that
.$validator({
account: [
required(required.message("手机号码")),
chs_phone(chs_phone.message())
],
captcha: [
required(required.message("验证码")),
alpha_num(alpha_num.message("验证码"))
]
})
.validate({
account,
captcha
});
} catch (e) {
return validatorDefaultCatch(e);
}
loginMobile({
phone: that.account,
captcha: that.captcha,
spread: cookie.get("spread")
})
.then(res => {
var data = res.data;
that.$store.commit("login", data.token, dayjs(data.expires_time));
handleGetUserInfo();
})
.catch(err => {
uni.showToast({
title: err.msg || err.response.data.msg || err.response.data.message,
icon: "none",
duration: 2000
});
});
},
async register() {
var that = this;
const {
account,
captcha,
password
} = that;
try {
await that
.$validator({
account: [
required(required.message("手机号码")),
chs_phone(chs_phone.message())
],
captcha: [
required(required.message("验证码")),
alpha_num(alpha_num.message("验证码"))
],
password: [
required(required.message("密码")),
attrs.range([6, 16], attrs.range.message("密码")),
alpha_num(alpha_num.message("密码"))
]
})
.validate({
account,
captcha,
password
});
} catch (e) {
return validatorDefaultCatch(e);
}
register({
account: that.account,
captcha: that.captcha,
password: that.password,
inviteCode: that.inviteCode,
spread: cookie.get("spread")
})
.then(res => {
uni.showToast({
title: res.msg,
icon: "success",
duration: 2000
});
that.formItem = 1;
})
.catch(err => {
uni.showToast({
title: err.msg || err.response.data.msg || err.response.data.message,
icon: "none",
duration: 2000
});
});
},
async code() {
var that = this;
const {
account
} = that;
try {
await that
.$validator({
account: [
required(required.message("手机号码")),
chs_phone(chs_phone.message())
]
})
.validate({
account
});
} catch (e) {
return validatorDefaultCatch(e);
}
if (that.formItem == 2) that.type = "register";
await registerVerify({
phone: that.account,
type: that.type
})
.then(res => {
uni.showToast({
title: res.msg,
icon: "success",
duration: 2000
});
that.sendCode();
})
.catch(err => {
uni.showToast({
title: err.msg || err.response.data.msg || err.response.data.message,
icon: "none",
duration: 2000
});
});
},
navTap: function (index) {
this.current = index;
},
async submit() {
const {
account,
password
} = this;
try {
await this.$validator({
account: [
required(required.message("账号")),
attrs.range([5, 16], attrs.range.message("账号")),
alpha_num(alpha_num.message("账号"))
],
password: [
required(required.message("密码")),
attrs.range([6, 16], attrs.range.message("密码")),
alpha_num(alpha_num.message("密码"))
]
}).validate({
account,
password
});
} catch (e) {
return validatorDefaultCatch(e);
}
login({
username: account,
password,
spread: cookie.get("spread")
})
.then(({
data
}) => {
this.$store.commit("login", data.token, dayjs(data.expires_time));
handleGetUserInfo();
// let replace=this.$yroute.query.replace
// if(replace){
// }
// this.$yrouter.replace({
// path: this.$yroute.query.replace || '/pages/home/index'
// });
})
.catch(err => {
console.log(err);
uni.showToast({
title: err.msg || err.response.data.msg || err.response.data.message,
icon: "none",
duration: 2000
});
});
}
}
};
</script>

4
pages/user/PersonalData/index.vue

@ -39,7 +39,8 @@
<view class="item acea-row row-between-wrapper">
<view>手机号</view>
<view class="input">
<input type="text" v-if="userInfo.phone" v-model="userInfo.phone" />
<!-- <input type="text" v-model="userInfo.phone" placeholder="未绑定"/> -->
<input type="text" v-if="userInfo.phone" v-model="userInfo.phone" placeholder="未绑定"/>
<input type="text" v-else value="未绑定" disabled class="id" />
</view>
</view>
@ -156,7 +157,6 @@ export default {
},
chooseImage() {
chooseImage((img) => {
console.log(img);
this.avatar = img;
});
},

180
pages/user/User/index.vue

@ -1,7 +1,11 @@
<template>
<view class="user">
<view v-if="$store.getters.token || userInfo.uid">
<view class="header bg-color-red acea-row row-between-wrapper">
<view class="getUserBaseData header bg-color-red acea-row row-between-wrapper" v-if="!userInfo.avatar && !userInfo.nickname">
<button class="userDataBtn" v-if="canIUseGetUserProfile" @tap="getUserInfoProfile">授权并查看用户信息</button>
<button class="userDataBtn" v-else @getuserinfo="getUserInfo" open-type="getUserInfo">授权并查看用户信息</button>
</view>
<view class="header bg-color-red acea-row row-between-wrapper" v-else>
<view class="picTxt acea-row row-between-wrapper">
<view class="pictrue">
<image :src="userInfo.avatar" />
@ -19,15 +23,15 @@
<text class="iconfont icon-bianji1"></text>
</view>
<!-- #ifdef MP-WEIXIN -->
<button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" class="binding" v-else>
<!-- <button open-type="getPhoneNumber" @getphonenumber="getPhoneNumber" class="binding" v-else>
<text>绑定手机号</text>
</button>
</button> -->
<!-- #endif -->
<!-- #ifndef MP-WEIXIN -->
<button class="binding" @click="goBindPhone()" v-else>
<!-- <button class="binding" @click="goBindPhone()" v-else>
<text>绑定手机号</text>
</button>
</button> -->
<!-- #endif -->
</view>
</view>
@ -128,11 +132,11 @@
</template>
<script>
import { mapState, mapGetters, mapMutations, mapActions } from 'vuex'
import { getUserInfo, getMenuUser, bindingPhone, wxappBindingPhone } from '@/api/user'
import { isWeixin, VUE_APP_RESOURCES_URL } from '@/utils'
import cookie from '@/utils/store/cookie'
import { getUserInfo, getMenuUser, wxappAuth, bindingPhone, wxappBindingPhone, wxappGetUserInfo } from '@/api/user'
import { isWeixin, VUE_APP_RESOURCES_URL, parseQuery, getProvider } from '@/utils'
import SwitchWindow from '@/components/SwitchWindow'
import Authorization from '@/pages/authorization/index'
import cookie from '@/utils/store/cookie'
const NAME = 'User'
@ -145,14 +149,23 @@ export default {
props: {},
data: function() {
return {
MyMenus: [],
switchActive: false,
isWeixin: false,
canIUseGetUserProfile: false,
MyMenus: [],
switchActive: false,
isWeixin: false,
}
},
computed: mapGetters(['userInfo']),
onLoad() {
if (wx.getUserProfile) {
this.canIUseGetUserProfile = true
}
},
methods: {
...mapMutations(['updateAuthorizationPage']),
toLogin() {
this.$yrouter.push('/pages/user/Login/index')
},
goReturnList() {
this.$yrouter.push('/pages/order/ReturnList/index')
},
@ -165,9 +178,7 @@ export default {
})
},
goBindPhone() {
this.$yrouter.push({
path: '/pages/user/BindingPhone/index',
})
this.$yrouter.push('/pages/user/BindingPhone/index')
},
goUserCoupon() {
this.$yrouter.push('/pages/user/coupon/UserCoupon/index')
@ -179,45 +190,41 @@ export default {
this.$yrouter.push('/pages/user/promotion/UserPromotion/index')
},
goUserAccount() {
this.$yrouter.push({
path: '/pages/user/UserAccount/index',
})
this.$yrouter.push('/pages/user/UserAccount/index')
},
goPersonalData() {
this.$yrouter.push('/pages/user/PersonalData/index')
},
getPhoneNumber: function(e) {
let thit = this
console.log(e)
//
if (e.mp.detail.errMsg == 'getPhoneNumber:ok') {
uni.showLoading({
title: '绑定中',
})
wxappBindingPhone({
encryptedData: e.mp.detail.encryptedData,
iv: e.mp.detail.iv,
})
.then(res => {
// this.User();
thit.$store.dispatch('userInfo', true)
uni.hideLoading()
uni.showToast({
title: res.msg,
icon: 'success',
duration: 2000,
})
})
.catch(error => {
uni.hideLoading()
thit.$store.dispatch('userInfo', true)
console.log(error)
uni.showToast({
title: error.msg || error.response.data.msg || error.response.data.message,
icon: 'none',
duration: 2000,
})
})
getPhoneNumber (e) {
//
if (e.mp.detail.errMsg == 'getPhoneNumber:ok') {
uni.showLoading({
title: '绑定中',
})
wxappBindingPhone({
encryptedData: e.mp.detail.encryptedData,
iv: e.mp.detail.iv,
})
.then(res => {
// this.User();
this.$store.dispatch('userInfo', true)
uni.hideLoading()
uni.showToast({
title: res.msg,
icon: 'success',
duration: 2000,
})
})
.catch(error => {
uni.hideLoading()
this.$store.dispatch('userInfo', true)
console.log(error)
uni.showToast({
title: error.msg || error.response.data.msg || error.response.data.message,
icon: 'none',
duration: 2000,
})
})
// //
// uni.getProvider({
// service: "oauth",
@ -233,7 +240,7 @@ export default {
// })
// .then(res => {
// // this.User();
// thit.$store.dispatch("userInfo", true);
// this.$store.dispatch("userInfo", true);
// uni.hideLoading();
// uni.showToast({
// title: res.msg,
@ -243,7 +250,7 @@ export default {
// })
// .catch(error => {
// uni.hideLoading();
// thit.$store.dispatch("userInfo", true);
// this.$store.dispatch("userInfo", true);
// console.log(error);
// uni.showToast({
// title: error.msg ||
@ -264,15 +271,67 @@ export default {
// reject("");
// }
// });
} else {
} else {
uni.showToast({
title: '已拒绝授权',
icon: 'none',
duration: 2000,
})
}
},
//
getUserInfo(data) {
if (data.detail.errMsg == 'getUserInfo:fail auth deny') {
uni.showToast({
title: '已拒绝授权',
title: '取消授权',
icon: 'none',
duration: 2000,
})
return
}
},
changeswitch(data) {
//
getUserInfoProfile(data) {
wx.getUserProfile({
lang: 'zh_CN',
desc: '需要获取您的信息用来展示',
success: res => {
uni.showLoading({
title: '正在更新信息...',
duration: 2000,
})
getProvider()
.then(provider => { //
if (!provider) {
reject()
}
// code
uni.login({
provider: provider,
success: async loginRes => {
wxappGetUserInfo({
encryptedData: res.encryptedData,
iv: res.iv,
code: loginRes.code, // code
}).then(res => {
console.log(res === 200)
if (res.status === 200) {
this.userInfo.avatar = res.data.avatar
this.userInfo.nickname = res.data.nickname
} else {
uni.showLoading({
title: res.msg,
duration: 2000,
})
}
})
}
})
})
}
})
},
changeswitch(data) {
this.switchActive = data
},
//
@ -357,6 +416,19 @@ export default {
</script>
<style lang="less">
.getUserBaseData{
.userDataBtn{
width: 80%;
height: 80rpx;
background: linear-gradient(to right, #f35447 0%, #ff8e3c 100%);
background: -moz-linear-gradient(to right, #f35447 0%, #ff8e3c 100%);
border-radius: 40rpx;
font-size: 30rpx;
font-family: PingFang SC;
font-weight: 500;
color: rgba(255, 255, 255, 1);
}
}
.footer-line-height {
height: 1 * 100rpx;
}

19
pages/user/coupon/GetCoupon/index.vue

@ -97,18 +97,17 @@ export default {
})
})
},
getUseCoupons: function() {
let that = this
if (that.loading) return //false
if (that.loadend) return //false
that.loading = true
let q = { page: that.page, limit: that.limit }
getUseCoupons() {
if (this.loading) return //false
if (this.loadend) return //false
this.loading = true
let q = { page: this.page, limit: this.limit }
getCoupon(q).then(res => {
that.loading = false
this.loading = false
//apply();js;
that.couponsList.push.apply(that.couponsList, res.data)
that.loadend = res.data.length < that.limit //
that.page = that.page + 1
this.couponsList.push.apply(this.couponsList, res.data)
this.loadend = res.data.length < this.limit //
this.page = this.page + 1
})
},
},

4
pages/user/signIn/Sign/index.vue

@ -7,9 +7,9 @@
<image :src="userInfo.avatar" />
</view>
<view class="text">
<view class="line1">{{ userInfo.nickname }}</view>
<view class="line1">{{ userInfo.nickname || '' }}</view>
<view class="integral acea-row">
<text>积分: {{ userInfo.integral }}</text>
<text>积分: {{ userInfo.integral || 0 }}</text>
</view>
</view>
</view>

14
utils/index.js

@ -2,7 +2,7 @@ import Vue from 'vue'
// import MpvueRouterPatch from 'mpvue-router-patch'
// Vue.use(MpvueRouterPatch)
import { wxappAuth, getUserInfo } from '@/api/user'
import { wxappAuth, getUserInfo, wxappBindingPhone } from '@/api/user'
import store from '@/store'
import dayjs from 'dayjs'
import cookie from '@/utils/store/cookie'
@ -164,7 +164,7 @@ export const getProvider = service => {
},
})
}).catch(error => {
console.log(error)
console.log('167',error)
})
}
@ -196,7 +196,7 @@ export const login = loginInfo => {
auth(code)
.then(() => {
let redirect = cookie.get('redirect').replace(/\ /g, '')
console.log(redirect)
console.log('199',redirect)
if (redirect) {
redirect = redirect.split('/pages')[1]
if (!redirect) {
@ -286,9 +286,8 @@ export const login = loginInfo => {
reject('获取用户信息失败')
})
})
.catch(error => {
.catch(error => { // 登录接口调用失败
console.log(error)
console.log('登录接口调用失败')
reject('登录接口调用失败')
})
} else {
@ -299,18 +298,17 @@ export const login = loginInfo => {
uni.getUserInfo({
provider: provider,
success: function(user) {
console.log(user)
console.log('获取用户信息成功')
console.log('开始调用登录接口')
wxappAuth({
// phone: user.phone
encryptedData: user.encryptedData,
iv: user.iv,
code: code,
spread: cookie.get('spread'),
})
.then(({ data }) => {
console.log('登录接口调用成功')
console.log('开始处理登录信息保存,并获取用户详情')
console.log('登录成功,开始处理登录信息保存,并获取用户详情')
uni.hideLoading()
store.commit('login', data.token, dayjs(data.expires_time))
store.dispatch('userInfo', true)

17
utils/request.js

@ -20,6 +20,16 @@ import cookie from '@/utils/store/cookie'
const fly = new Fly()
fly.config.baseURL = VUE_APP_API_URL
// 小程序请求域名
// #ifdef MP-WEIXIN
fly.config.baseURL = 'http://itxzz.51vip.biz/api'
// #endif
// #ifdef APP-PLUS
// app端
fly.config.baseURL = 'http://itxzz.51vip.biz/api'
// #endif
fly.interceptors.response.use(
response => {
// console.log(response)
@ -27,9 +37,10 @@ fly.interceptors.response.use(
return response
},
error => {
console.log(error)
if (error.toString() == 'Error: Network Error') {
console.log('————————')
console.log('发送请求失败', error)
console.log('请求失败', error)
console.log('————————')
handleLoginFailure()
return Promise.reject({ msg: '未登录', toLogin: true })
@ -123,9 +134,9 @@ const request = ['post', 'put', 'patch'].reduce((request, method) => {
return baseRequest(Object.assign({ url, data, method }, defaultOpt, options))
}
return request
}, {})
}, {});
;['get', 'delete', 'head'].forEach(method => {
['get', 'delete', 'head'].forEach(method => {
/**
*
* @param url string 接口地址

Loading…
Cancel
Save