bugfix
This commit is contained in:
@ -1,5 +1,6 @@
|
|||||||
// pages/login/login.js
|
// pages/login/login.js
|
||||||
var app = getApp()
|
const app = getApp()
|
||||||
|
const IP = app.globalData.ip;
|
||||||
Page({
|
Page({
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -9,8 +10,33 @@ Page({
|
|||||||
ip: app.globalData.ip,
|
ip: app.globalData.ip,
|
||||||
pId: 0,// 上级id 默认0,
|
pId: 0,// 上级id 默认0,
|
||||||
goodsId: 0,
|
goodsId: 0,
|
||||||
|
avatarUrl: "",
|
||||||
|
nickName: ""
|
||||||
|
},
|
||||||
|
bindNickNameInput(e) {
|
||||||
|
this.setData({
|
||||||
|
nickName: e.detail.value
|
||||||
|
})
|
||||||
|
},
|
||||||
|
onChooseAvatar(e) {
|
||||||
|
const { avatarUrl } = e.detail
|
||||||
|
wx.uploadFile({
|
||||||
|
url: IP + '/wisdommining/api/user/img',
|
||||||
|
filePath: avatarUrl,
|
||||||
|
name: 'file',
|
||||||
|
success: (res) => {
|
||||||
|
const data = JSON.parse(res.data)
|
||||||
|
this.setData({
|
||||||
|
avatarUrl: data.src,
|
||||||
|
})
|
||||||
|
},
|
||||||
|
fail: () => {
|
||||||
|
wx.showToast({
|
||||||
|
title: '头像上传失败',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
},
|
},
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 生命周期函数--监听页面加载
|
* 生命周期函数--监听页面加载
|
||||||
*/
|
*/
|
||||||
@ -31,114 +57,158 @@ Page({
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
|
||||||
getUserProfile(e) {
|
getUserProfile(e) {
|
||||||
// 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
|
// 推荐使用wx.getUserProfile获取用户信息,开发者每次通过该接口获取用户个人信息均需用户确认
|
||||||
// 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
|
// 开发者妥善保管用户快速填写的头像昵称,避免重复弹窗
|
||||||
wx.showLoading({
|
wx.showLoading({
|
||||||
title: '登录中',
|
title: '登录中',
|
||||||
})
|
})
|
||||||
wx.getUserProfile({
|
const { avatarUrl, nickName } = this.data
|
||||||
desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
|
if (!avatarUrl) {
|
||||||
success: (res) => {
|
wx.showToast({
|
||||||
console.log(res)
|
title: '请点击头像选择头像',
|
||||||
if (res.iv) {
|
})
|
||||||
let name = res.userInfo.nickName;
|
return
|
||||||
let photo = res.userInfo.avatarUrl;
|
|
||||||
wx.login({
|
|
||||||
success: res => {
|
|
||||||
if (res.code) {
|
|
||||||
wx.request({
|
|
||||||
url: app.globalData.ip + '/wisdommining/api/wechat/getOpenid',
|
|
||||||
data: {
|
|
||||||
code: res.code,
|
|
||||||
},
|
|
||||||
success: suc => {
|
|
||||||
console.log(suc);
|
|
||||||
if (suc.data.code == 1) {
|
|
||||||
this.login({
|
|
||||||
openid: suc.data.value,
|
|
||||||
nicename: name,
|
|
||||||
photo: photo
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
wx.showModal({
|
|
||||||
title: '提示!',
|
|
||||||
content: suc.data.message,
|
|
||||||
showCancel: false,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: f => {
|
|
||||||
console.log(f)
|
|
||||||
}
|
|
||||||
});
|
|
||||||
} else {
|
|
||||||
console.log('获取用户登录态失败!' + res.errMsg)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
wx.showToast({
|
|
||||||
title: '登录失败~',
|
|
||||||
icon: 'none'
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})
|
|
||||||
},
|
|
||||||
//登录
|
|
||||||
login(options) {
|
|
||||||
console.log(options)
|
|
||||||
wx.request({
|
|
||||||
url: app.globalData.ip + '/wisdommining/api/wechat/addUser',
|
|
||||||
method: 'POST',
|
|
||||||
data: {
|
|
||||||
wxNickname: options.nicename,
|
|
||||||
wxPhoto: options.photo,
|
|
||||||
wxOpenid: options.openid,
|
|
||||||
userPid: parseInt(this.data.pId)
|
|
||||||
},
|
|
||||||
success: res => {
|
|
||||||
console.log(res);
|
|
||||||
if (res.data.code == 1) {
|
|
||||||
wx.setStorage({
|
|
||||||
key: 'user',
|
|
||||||
data: res.data.value,
|
|
||||||
})
|
|
||||||
//获取ID
|
|
||||||
app.globalData.userId = res.data.value.id;
|
|
||||||
wx.hideLoading()
|
|
||||||
wx.showToast({
|
|
||||||
title: '登录成功~',
|
|
||||||
icon: 'none',
|
|
||||||
success: ss => {
|
|
||||||
|
|
||||||
if (this.data.goodsId != 0) {
|
|
||||||
//商品跳转
|
|
||||||
wx.reLaunch({
|
|
||||||
url: '/pages/goodsDetails/goodsDetails?goodsId=' + this.data.goodsId,
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
//正常跳转
|
|
||||||
wx.reLaunch({
|
|
||||||
url: '/pages/my/my',
|
|
||||||
})
|
|
||||||
}
|
|
||||||
})
|
|
||||||
} else {
|
|
||||||
wx.showModal({
|
|
||||||
title: '提示!',
|
|
||||||
content: res.data.message,
|
|
||||||
showCancel: false,
|
|
||||||
})
|
|
||||||
}
|
|
||||||
},
|
|
||||||
fail: f => {
|
|
||||||
console.log(res)
|
|
||||||
}
|
}
|
||||||
});
|
if (!nickName) {
|
||||||
},
|
wx.showToast({
|
||||||
|
title: '请输入昵称',
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
wx.login({
|
||||||
|
success: res => {
|
||||||
|
if (res.code) {
|
||||||
|
wx.request({
|
||||||
|
url: app.globalData.ip + '/wisdommining/api/wechat/getOpenid',
|
||||||
|
data: {
|
||||||
|
code: res.code,
|
||||||
|
},
|
||||||
|
success: suc => {
|
||||||
|
if (suc.data.code == 1) {
|
||||||
|
this.login({
|
||||||
|
openid: suc.data.value,
|
||||||
|
nicename: nickName,
|
||||||
|
photo: avatarUrl
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
wx.showModal({
|
||||||
|
title: '提示!',
|
||||||
|
content: suc.data.message,
|
||||||
|
showCancel: false,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: f => {
|
||||||
|
console.log(f)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
console.log('获取用户登录态失败!' + res.errMsg)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
})
|
||||||
|
// wx.getUserProfile({
|
||||||
|
// desc: '用于完善会员资料', // 声明获取用户个人信息后的用途,后续会展示在弹窗中,请谨慎填写
|
||||||
|
// success: (res) => {
|
||||||
|
// console.log(res)
|
||||||
|
// if (res.iv) {
|
||||||
|
// let name = res.userInfo.nickName;
|
||||||
|
// let photo = res.userInfo.avatarUrl;
|
||||||
|
// wx.login({
|
||||||
|
// success: res => {
|
||||||
|
// if (res.code) {
|
||||||
|
// wx.request({
|
||||||
|
// url: app.globalData.ip + '/wisdommining/api/wechat/getOpenid',
|
||||||
|
// data: {
|
||||||
|
// code: res.code,
|
||||||
|
// },
|
||||||
|
// success: suc => {
|
||||||
|
// console.log(suc);
|
||||||
|
// if (suc.data.code == 1) {
|
||||||
|
// this.login({
|
||||||
|
// openid: suc.data.value,
|
||||||
|
// nicename: name,
|
||||||
|
// photo: photo
|
||||||
|
// })
|
||||||
|
// } else {
|
||||||
|
// wx.showModal({
|
||||||
|
// title: '提示!',
|
||||||
|
// content: suc.data.message,
|
||||||
|
// showCancel: false,
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// },
|
||||||
|
// fail: f => {
|
||||||
|
// console.log(f)
|
||||||
|
// }
|
||||||
|
// });
|
||||||
|
// } else {
|
||||||
|
// console.log('获取用户登录态失败!' + res.errMsg)
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
// } else {
|
||||||
|
// wx.showToast({
|
||||||
|
// title: '登录失败~',
|
||||||
|
// icon: 'none'
|
||||||
|
// })
|
||||||
|
// }
|
||||||
|
// }
|
||||||
|
// })
|
||||||
|
},
|
||||||
|
//登录
|
||||||
|
login(options) {
|
||||||
|
wx.request({
|
||||||
|
url: app.globalData.ip + '/wisdommining/api/wechat/addUser',
|
||||||
|
method: 'POST',
|
||||||
|
data: {
|
||||||
|
wxNickname: options.nicename,
|
||||||
|
wxPhoto: options.photo,
|
||||||
|
wxOpenid: options.openid,
|
||||||
|
userPid: parseInt(this.data.pId)
|
||||||
|
},
|
||||||
|
success: res => {
|
||||||
|
console.log(res);
|
||||||
|
if (res.data.code == 1) {
|
||||||
|
wx.setStorage({
|
||||||
|
key: 'user',
|
||||||
|
data: res.data.value,
|
||||||
|
})
|
||||||
|
//获取ID
|
||||||
|
app.globalData.userId = res.data.value.id;
|
||||||
|
wx.hideLoading()
|
||||||
|
wx.showToast({
|
||||||
|
title: '登录成功~',
|
||||||
|
icon: 'none',
|
||||||
|
success: ss => {
|
||||||
|
|
||||||
|
if (this.data.goodsId != 0) {
|
||||||
|
//商品跳转
|
||||||
|
wx.reLaunch({
|
||||||
|
url: '/pages/goodsDetails/goodsDetails?goodsId=' + this.data.goodsId,
|
||||||
|
})
|
||||||
|
return
|
||||||
|
}
|
||||||
|
//正常跳转
|
||||||
|
wx.reLaunch({
|
||||||
|
url: '/pages/my/my',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
} else {
|
||||||
|
wx.showModal({
|
||||||
|
title: '提示!',
|
||||||
|
content: res.data.message,
|
||||||
|
showCancel: false,
|
||||||
|
})
|
||||||
|
}
|
||||||
|
},
|
||||||
|
fail: f => {
|
||||||
|
console.log(res)
|
||||||
|
}
|
||||||
|
});
|
||||||
|
},
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -7,8 +7,15 @@
|
|||||||
<image src="/icon/login-bj.png" class="login-bj"></image>
|
<image src="/icon/login-bj.png" class="login-bj"></image>
|
||||||
<view class="login-title">微信授权</view>
|
<view class="login-title">微信授权</view>
|
||||||
<view class='login-logo'>
|
<view class='login-logo'>
|
||||||
<open-data type="userAvatarUrl"></open-data>
|
<!-- <open-data type="userAvatarUrl"></open-data> -->
|
||||||
|
<button class="avatar-wrapper" open-type="chooseAvatar" bind:chooseavatar="onChooseAvatar">
|
||||||
|
<image class="avatar" src="{{avatarUrl}}"></image>
|
||||||
|
</button>
|
||||||
</view>
|
</view>
|
||||||
|
<div class="nickname">
|
||||||
|
<div>昵称</div>
|
||||||
|
<input type="nickname" style="border-width: 14rpx;border-color: gray;" placeholder="请输入昵称" bindinput="bindNickNameInput" />
|
||||||
|
</div>
|
||||||
<view class="login-name">三品采慧</view>
|
<view class="login-name">三品采慧</view>
|
||||||
<view class="login-text">为您的公司定制不一样的礼包套餐~</view>
|
<view class="login-text">为您的公司定制不一样的礼包套餐~</view>
|
||||||
</view>
|
</view>
|
||||||
|
@ -1,76 +1,91 @@
|
|||||||
/* pages/login/login.wxss */
|
/* pages/login/login.wxss */
|
||||||
page{
|
page {
|
||||||
background: #f5f5f5;
|
background: #f5f5f5;
|
||||||
}
|
}
|
||||||
.main{
|
.main {
|
||||||
position: relative
|
position: relative;
|
||||||
}
|
}
|
||||||
.login-top{
|
.login-top {
|
||||||
width: 750rpx;
|
width: 750rpx;
|
||||||
height: 376rpx;
|
height: 376rpx;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top:0;
|
top: 0;
|
||||||
left: 0;
|
left: 0;
|
||||||
}
|
}
|
||||||
.login-top image{
|
.login-top image {
|
||||||
width: 750rpx;
|
width: 750rpx;
|
||||||
height: 376rpx;
|
height: 376rpx;
|
||||||
}
|
}
|
||||||
.login-content{
|
.login-content {
|
||||||
width: 690rpx;
|
width: 690rpx;
|
||||||
height: 887rpx;
|
height: 887rpx;
|
||||||
border-radius: 40rpx;
|
border-radius: 40rpx;
|
||||||
position: relative;
|
position: relative;
|
||||||
top:54rpx;
|
top: 54rpx;
|
||||||
left: 30rpx;
|
left: 30rpx;
|
||||||
}
|
}
|
||||||
.login-bj{
|
.login-bj {
|
||||||
width: 690rpx;
|
width: 690rpx;
|
||||||
height: 887rpx;
|
height: 887rpx;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
left:0;
|
left: 0;
|
||||||
top:0;
|
top: 0;
|
||||||
}
|
}
|
||||||
.login-title{
|
.login-title {
|
||||||
font-size: 36rpx;
|
font-size: 36rpx;
|
||||||
color: #ee7b1e;
|
color: #ee7b1e;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
position: relative;
|
position: relative;
|
||||||
top:130rpx;
|
top: 130rpx;
|
||||||
}
|
}
|
||||||
.login-logo{
|
.login-logo {
|
||||||
width: 120rpx;
|
width: 120rpx;
|
||||||
height: 120rpx;
|
height: 120rpx;
|
||||||
border-radius: 100%;
|
border-radius: 100%;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top:256rpx;
|
top: 256rpx;
|
||||||
left:281rpx;
|
left: 281rpx;
|
||||||
}
|
}
|
||||||
.login-name{
|
.login-logo .avatar-wrapper {
|
||||||
font-size: 36rpx;
|
padding: 0;
|
||||||
color: #ee7b1e;
|
width: 120rpx !important;
|
||||||
|
height: 120rpx !important;
|
||||||
|
}
|
||||||
|
.login-logo .avatar-wrapper .avatar {
|
||||||
|
width: 120rpx;
|
||||||
|
height: 120rpx;
|
||||||
|
}
|
||||||
|
.nickname {
|
||||||
|
display: flex;
|
||||||
|
width: 400rpx;
|
||||||
|
justify-content: space-between;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top:600rpx;
|
left: 175rpx;
|
||||||
left:270rpx;
|
top: 460rpx;
|
||||||
}
|
}
|
||||||
.login-text{
|
.login-name {
|
||||||
|
font-size: 36rpx;
|
||||||
|
color: #ee7b1e;
|
||||||
|
position: absolute;
|
||||||
|
top: 600rpx;
|
||||||
|
left: 270rpx;
|
||||||
|
}
|
||||||
|
.login-text {
|
||||||
font-size: 28rpx;
|
font-size: 28rpx;
|
||||||
color: #6e6b79;
|
color: #6e6b79;
|
||||||
position: absolute;
|
position: absolute;
|
||||||
top:680rpx;
|
top: 680rpx;
|
||||||
left:119rpx;
|
left: 119rpx;
|
||||||
}
|
}
|
||||||
.btn{
|
.btn {
|
||||||
width: 690rpx;
|
width: 690rpx;
|
||||||
height: 88rpx;
|
height: 88rpx;
|
||||||
background-image: linear-gradient(-90deg,
|
background-image: linear-gradient(-90deg, #ee7b1e 0%, #fdae03 100%);
|
||||||
#ee7b1e 0%,
|
border-radius: 44rpx;
|
||||||
#fdae03 100%);
|
|
||||||
border-radius: 44rpx;
|
|
||||||
font-size: 36rpx;
|
font-size: 36rpx;
|
||||||
line-height: 88rpx;
|
line-height: 88rpx;
|
||||||
color: #ffffff;
|
color: #ffffff;
|
||||||
text-align: center;
|
text-align: center;
|
||||||
padding: 0;
|
padding: 0;
|
||||||
margin-top: 170rpx;
|
margin-top: 170rpx;
|
||||||
|
@ -1,11 +1,11 @@
|
|||||||
<wxs module="findGoods">
|
<wxs module="findGoodsByName">
|
||||||
function findGoods(goodsList, id) {
|
function findGoodsByName(goodsList, name, spec) {
|
||||||
// 初始化一个变量来存储找到的商品
|
// 初始化一个变量来存储找到的商品
|
||||||
var found = null;
|
var found = null;
|
||||||
|
|
||||||
// 遍历商品列表以查找具有指定ID的商品
|
// 遍历商品列表以查找具有指定ID的商品
|
||||||
for (var i = 0; i < goodsList.length; i++) {
|
for (var i = 0; i < goodsList.length; i++) {
|
||||||
if (goodsList[i].id === id) {
|
if (goodsList[i].goodsName === name && goodsList[i].wisdGoodsSpec.specName === spec) {
|
||||||
found = goodsList[i];
|
found = goodsList[i];
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@ -20,9 +20,10 @@
|
|||||||
return undefined;
|
return undefined;
|
||||||
}
|
}
|
||||||
module.exports = {
|
module.exports = {
|
||||||
findGoods: findGoods,
|
findGoodsByName: findGoodsByName,
|
||||||
}
|
}
|
||||||
</wxs>
|
</wxs>
|
||||||
|
|
||||||
<wxs module="num">
|
<wxs module="num">
|
||||||
function toFixed(num, precise) {
|
function toFixed(num, precise) {
|
||||||
return typeof (num) === "undefined" ? num : num.toFixed(precise)
|
return typeof (num) === "undefined" ? num : num.toFixed(precise)
|
||||||
@ -76,13 +77,13 @@
|
|||||||
</view>
|
</view>
|
||||||
<view class="cont display_J_B" wx:for='{{item.goods}}' wx:key="specId" wx:for-item="goodsItem" catchtap="">
|
<view class="cont display_J_B" wx:for='{{item.goods}}' wx:key="specId" wx:for-item="goodsItem" catchtap="">
|
||||||
<view class="cont-l">
|
<view class="cont-l">
|
||||||
<image src="{{ goods.orderPayWay == 3? goods.goodsList[0].goodsPhoto: findGoods.findGoods(goods.goodsList,goodsItem.id).goodsPhoto }}"></image>
|
<image src="{{ goods.orderPayWay == 3? goods.goodsList[0].goodsPhoto: findGoodsByName.findGoodsByName(goods.goodsList,goodsItem.name,goodsItem.spec).goodsPhoto }}"></image>
|
||||||
</view>
|
</view>
|
||||||
<view class="cont-m">
|
<view class="cont-m">
|
||||||
<view class="name GStitleOne">{{goodsItem.name}}</view>
|
<view class="name GStitleOne">{{goodsItem.name}}</view>
|
||||||
<view class="specs" wx:if="{{goods.orderPayWay!=3}}">规格:{{goodsItem.spec}}</view>
|
<view class="specs" wx:if="{{goods.orderPayWay!=3}}">规格:{{goodsItem.spec}}</view>
|
||||||
<view class="price" wx:if="{{goods.orderPayWay!=3}}">
|
<view class="price" wx:if="{{goods.orderPayWay!=3}}">
|
||||||
{{goods.orderPayWay!=2?'¥'+findGoods.findGoods(goods.goodsList,goodsItem.id).price:findGoods.findGoods(goods.goodsList,goodsItem.id).price+'积分'}}
|
{{goods.orderPayWay!=2?'¥'+findGoodsByName.findGoodsByName(goods.goodsList,goodsItem.name,goodsItem.spec).wisdGoodsSpec.specPrice:findGoodsByName.findGoodsByName(goods.goodsList,goodsItem.name,goodsItem.spec).wisdGoodsSpec.specPrice+'积分'}}
|
||||||
</view>
|
</view>
|
||||||
<view class="price" wx:if="{{goods.orderPayWay==3}}">¥0</view>
|
<view class="price" wx:if="{{goods.orderPayWay==3}}">¥0</view>
|
||||||
</view>
|
</view>
|
||||||
|
@ -94,5 +94,5 @@
|
|||||||
},
|
},
|
||||||
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
|
"description": "项目私有配置文件。此文件中的内容将覆盖 project.config.json 中的相同字段。项目的改动优先同步到此文件中。详见文档:https://developers.weixin.qq.com/miniprogram/dev/devtools/projectconfig.html",
|
||||||
"projectname": "%E4%B8%89%E5%93%81%E6%85%A7%E9%87%873",
|
"projectname": "%E4%B8%89%E5%93%81%E6%85%A7%E9%87%873",
|
||||||
"libVersion": "2.14.1"
|
"libVersion": "2.25.4"
|
||||||
}
|
}
|
Reference in New Issue
Block a user