Merge branch 'pplok' of pplokijuhyg/deguodaigou into master

This commit is contained in:
pplokijuhyg 2019-12-19 14:31:12 +08:00
commit 3924510d78
4 changed files with 81 additions and 7 deletions

View File

@ -7,9 +7,41 @@ Page({
*/
data: {
},
getinfo(a){
request({
url:"User/validateOpenid"
}).then((res)=>{
if(res.data.code == 400){
request({
url:"User/register",
data:{
country:"",
gender:0,
nick_name:a.detail.userInfo.nickName,
province:"",
city:"",
head_pic:a.detail.userInfo.avatarUrl,
open_id: wx.getStorageSync("openid"),
}
}).then((res)=>{
if(res.data.code == 200){
wx.switchTab({
url:"/pages/index/index"
})
}
})
}else{
wx.switchTab({
url:"/pages/index/index"
})
}
})
},
login(a){
console.log(a)
let i = this
wx.login({
success (res) {
if (res.code) {
@ -21,6 +53,11 @@ Page({
}
}).then((res)=>{
console.log(res)
wx.setStorageSync("openid",res.data.openid)
i.getinfo(a)
wx.switchTab({
url:"/pages/index/index"
})
})
} else {
console.log('登录失败!' + res.errMsg)

View File

@ -1,4 +1,5 @@
// pages/personal/personal.js
// pages/personal/personal.js.
import {request} from "../../utils/bin"
Page({
/**
@ -13,9 +14,7 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
this.setData({
openid:wx.getStorageSync("openid")
})
},
toorder() {
wx.navigateTo({
@ -57,6 +56,13 @@ Page({
/**
* 生命周期函数--监听页面初次渲染完成
*/
login(){
if(this.data.openid == ""){
wx.navigateTo({
url:"/pages/login/login"
})
}
},
onReady: function() {
},
@ -65,7 +71,14 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function() {
this.setData({
openid:wx.getStorageSync("openid")
})
request({
url:"User/validateOpenid"
}).then((res)=>{
console.log(res)
})
},
/**

View File

@ -1,18 +1,38 @@
// pages/shopping/shopping.js
import {request} from "../../utils/bin"
Page({
/**
* 页面的初始数据
*/
data: {
list:[1,1,1]
list:[1,1,1],
userid:0
},
/**
* 生命周期函数--监听页面加载
*/
getlist(){
request({
url:"Cart/cartList/session_id/" + wx.getStorageSync('openid'),
data:{
user_id:this.data.userid
}
}).then((res)=>{
console.log(res)
})
},
onLoad: function(options) {
request({
url:"User/validateOpenid"
}).then((res)=>{
console.log(res)
this.setData({
userid:res.data.data.user_id
})
this.getlist()
})
},
sub() {
wx.navigateTo({

View File

@ -16,6 +16,10 @@ let request = function (obj){
}
header['content-type'] = "application/x-www-form-urlencoded"
}
if(data == undefined){
data = {}
}
data.openid = wx.getStorageSync("openid")
return new Promise((res,rej)=>{
wx.request({
url,