Commit 5ec36300 by wangyalan-git

登录修改

parent 05cdd109
<?xml version="1.0" encoding="UTF-8"?>
<project version="4">
<component name="ChangeListManager">
<list default="true" id="749f7826-d70b-49cf-994d-3acd7b934330" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/images/icon/poster1@2x.png" beforeDir="false" afterPath="$PROJECT_DIR$/images/icon/poster1@2x.png" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/index/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/pages/index/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/index/index.wxml" beforeDir="false" afterPath="$PROJECT_DIR$/pages/index/index.wxml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/index/index.wxss" beforeDir="false" afterPath="$PROJECT_DIR$/pages/index/index.wxss" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/login/login.wxss" beforeDir="false" afterPath="$PROJECT_DIR$/pages/login/login.wxss" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/newDetail/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/pages/newDetail/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/newDetail/index.json" beforeDir="false" afterPath="$PROJECT_DIR$/pages/newDetail/index.json" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/newDetail/index.wxml" beforeDir="false" afterPath="$PROJECT_DIR$/pages/newDetail/index.wxml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/newDetail/index.wxss" beforeDir="false" afterPath="$PROJECT_DIR$/pages/newDetail/index.wxss" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/newsList/index.js" beforeDir="false" afterPath="$PROJECT_DIR$/pages/newsList/index.js" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/newsList/index.wxml" beforeDir="false" afterPath="$PROJECT_DIR$/pages/newsList/index.wxml" afterDir="false" />
<change beforePath="$PROJECT_DIR$/pages/newsList/index.wxss" beforeDir="false" afterPath="$PROJECT_DIR$/pages/newsList/index.wxss" afterDir="false" />
<change beforePath="$PROJECT_DIR$/project.config.json" beforeDir="false" afterPath="$PROJECT_DIR$/project.config.json" afterDir="false" />
</list>
<list default="true" id="749f7826-d70b-49cf-994d-3acd7b934330" name="Default Changelist" comment="" />
<ignored path="$PROJECT_DIR$/.tmp/" />
<ignored path="$PROJECT_DIR$/temp/" />
<ignored path="$PROJECT_DIR$/tmp/" />
......@@ -25,6 +11,19 @@
<option name="HIGHLIGHT_NON_ACTIVE_CHANGELIST" value="false" />
<option name="LAST_RESOLUTION" value="IGNORE" />
</component>
<component name="FileEditorManager">
<leaf>
<file pinned="false" current-in-tab="true">
<entry file="file://$PROJECT_DIR$/utils/config.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="88">
<caret line="4" lean-forward="true" selection-start-line="4" selection-end-line="4" />
</state>
</provider>
</entry>
</file>
</leaf>
</component>
<component name="Git.Settings">
<option name="RECENT_GIT_ROOT_PATH" value="$PROJECT_DIR$" />
</component>
......@@ -39,6 +38,7 @@
<foldersAlwaysOnTop value="true" />
</navigator>
<panes>
<pane id="Scope" />
<pane id="ProjectPane">
<subPane>
<expand>
......@@ -50,7 +50,6 @@
<select />
</subPane>
</pane>
<pane id="Scope" />
</panes>
</component>
<component name="PropertiesComponent">
......@@ -84,11 +83,12 @@
<updated>1603358883438</updated>
<workItem from="1603358884856" duration="655000" />
<workItem from="1604054385788" duration="4000" />
<workItem from="1604972001520" duration="6000" />
</task>
<servers />
</component>
<component name="TimeTrackingManager">
<option name="totallyTimeSpent" value="659000" />
<option name="totallyTimeSpent" value="665000" />
</component>
<component name="ToolWindowManager">
<frame x="-7" y="-7" width="1550" height="838" extended-state="6" />
......@@ -116,4 +116,13 @@
<component name="TypeScriptGeneratedFilesManager">
<option name="version" value="1" />
</component>
<component name="editorHistoryManager">
<entry file="file://$PROJECT_DIR$/utils/config.js">
<provider selected="true" editor-type-id="text-editor">
<state relative-caret-position="88">
<caret line="4" lean-forward="true" selection-start-line="4" selection-end-line="4" />
</state>
</provider>
</entry>
</component>
</project>
\ No newline at end of file
......@@ -12,6 +12,18 @@ App({
this.globalData.shareCode = wx.getStorageSync('shareCode')
}
},
tipGoLogin: function () {
const that = this
wx.showModal({
title: '前往登录',
content: '请先登录后操作',
success: function (res) {
if (res.confirm) {
that.goLogin()
}
}
})
},
goLogin: function () {
console.log("登录")
wx.navigateTo({
......
......@@ -2,6 +2,7 @@
var http = require("../../utils/http.js");
// var config = require("../../utils/config.js");
const Big = require("../../utils/big.min.js");
const app = getApp()
Page({
......@@ -35,6 +36,9 @@ Page({
* 生命周期函数--监听页面显示
*/
onShow: function () {
let token = wx.getStorageSync('token') ? true : false
if (token) {
wx.showLoading();
//加载购物车
var params = {
......@@ -66,9 +70,10 @@ Page({
}
};
http.request(params);
http.getCartCount();//重新计算购物车总数量
} else {
app.tipGoLogin()
}
},
/**
......@@ -153,7 +158,7 @@ Page({
break;
}
}
if(flag){
if (flag) {
break;
}
}
......
......@@ -57,11 +57,12 @@ Page({
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
onLoad: function (options) {
let token = wx.getStorageSync('token') ? true : false
this.setData({
prodId: options.prodid,
});
if (token) {
// 加载商品信息
this.getProdInfo();
// 加载评论数据
......@@ -70,6 +71,9 @@ Page({
this.getLittleProdComm();
// 查看用户是否关注
this.getCollection();
} else {
app.tipGoLogin()
}
},
/**
......@@ -240,7 +244,7 @@ Page({
/**
* 根据skuList进行数据组装
*/
groupSkuProp: function() {
groupSkuProp: function () {
var skuList = this.data.skuList;
//当后台返回只有一个SKU时,且SKU属性值为空时,即该商品没有规格选项,该SKU直接作为默认选中SKU
......@@ -307,7 +311,7 @@ Page({
},
//将已选的 {key:val,key2:val2}转换成 [val,val2]
parseSelectedObjToVals: function() {
parseSelectedObjToVals: function () {
var selectedPropObj = this.data.selectedPropObj;
var selectedProperties = "";
var selectedProp = [];
......@@ -336,7 +340,7 @@ Page({
},
//点击选择规格
toChooseItem: function(e) {
toChooseItem: function (e) {
var val = e.currentTarget.dataset.val;
var key = e.currentTarget.dataset.key;
var selectedPropObj = this.data.selectedPropObj;
......@@ -348,7 +352,7 @@ Page({
},
//判断数组是否包含某对象
array_contain: function(array, obj) {
array_contain: function (array, obj) {
for (var i = 0; i < array.length; i++) {
if (array[i] == obj) //如果要求数据类型也一致,这里可使用恒等号===
return true;
......@@ -359,14 +363,14 @@ Page({
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
onShow: function () {
this.setData({
totalCartNum: app.globalData.totalCartCount
});
......@@ -375,35 +379,35 @@ Page({
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
onShareAppMessage: function () {
// return {
// title: "商品详情分享",
// path:`/pages/prod/prod`
......@@ -413,7 +417,7 @@ Page({
/**
* 跳转到首页
*/
toHomePage: function() {
toHomePage: function () {
wx.switchTab({
url: '/pages/index/index',
})
......@@ -422,7 +426,7 @@ Page({
/**
* 跳转到购物车
*/
toCartPage: function() {
toCartPage: function () {
wx.switchTab({
url: '/pages/basket/basket',
})
......@@ -431,14 +435,16 @@ Page({
/**
* 加入购物车
*/
addToCart: function(event) {
addToCart: function (event) {
let token = wx.getStorageSync('token') ? true : false
if (!token) {
app.tipGoLogin()
return
}
if (!this.data.findSku) {
return;
}
var ths = this;
wx.showLoading({
mask: true
});
var params = {
url: "/p/shopCart/changeItem",
method: "POST",
......@@ -449,7 +455,7 @@ Page({
shopId: this.data.shopId,
skuId: this.data.defaultSku.skuId
},
callBack: function(res) {
callBack: function (res) {
//console.log(res);
ths.setData({
totalCartNum: ths.data.totalCartNum + ths.data.prodNum
......@@ -467,7 +473,12 @@ Page({
/**
* 立即购买
*/
buyNow: function() {
buyNow: function () {
let token = wx.getStorageSync('token') ? true : false
if (!token) {
app.tipGoLogin()
return
}
if (!this.data.findSku) {
return;
}
......@@ -486,7 +497,7 @@ Page({
/**
* 减数量
*/
onCountMinus: function() {
onCountMinus: function () {
var prodNum = this.data.prodNum;
if (prodNum > 1) {
this.setData({
......@@ -498,7 +509,7 @@ Page({
/**
* 加数量
*/
onCountPlus: function() {
onCountPlus: function () {
var prodNum = this.data.prodNum;
if (prodNum < 1000) {
this.setData({
......@@ -510,14 +521,14 @@ Page({
/**
* 分享设置
*/
onShareAppMessage: function(res) {
onShareAppMessage: function (res) {
return {
title: this.data.prodName,
path: '/pages/prod/prod?prodid=' + this.data.prodid
}
},
showPopup: function() {
showPopup: function () {
if (this.data.loadCouponIds) {
this.setData({
popupShow: true
......@@ -559,18 +570,18 @@ Page({
}
})
},
showSku: function() {
showSku: function () {
this.setData({
skuShow: true
});
},
showComment: function() {
showComment: function () {
this.setData({
commentShow: true
});
},
closePopup: function() {
closePopup: function () {
this.setData({
popupShow: false,
skuShow: false,
......
......@@ -65,7 +65,8 @@ Page({
//加载订单数字
var ths = this;
// var status = ths.data.status
wx.showLoading();
if (this.data.isLogin) {
var params = {
url: "/p/myOrder/orderCount",
method: "GET",
......@@ -80,6 +81,9 @@ Page({
http.request(params);
this.getUserAccount()
this.getPageInfo()
} else {
app.tipGoLogin()
}
},
/**
......
......@@ -21,7 +21,7 @@ function request(params, isGetTonken) {
dataType: 'json',
responseType: params.responseType == undefined ? 'text' : params.responseType,
success: function (res) {
console.log('res',res)
console.log('res', res)
wx.hideLoading()
if (res.statusCode == 200) {
console.log(res.data.code)
......@@ -33,7 +33,7 @@ function request(params, isGetTonken) {
} else {
if (params.errCallBack) {
params.errCallBack(res);
}else {
} else {
wx.showToast({
title: res.data.note,
icon: "none"
......@@ -53,6 +53,7 @@ function request(params, isGetTonken) {
// if (!globalData.isLanding) {
globalData.isLanding = true
//重新获取token,再次请求接口
getApp().tipGoLogin()
// getApp().goLogin()
// }
} else if (res.statusCode == 400) {
......@@ -72,7 +73,7 @@ function request(params, isGetTonken) {
}
},
fail: function (err) {
console.log('err',err)
console.log('err', err)
wx.hideLoading();
wx.showToast({
title: "服务器出了点小差",
......@@ -90,7 +91,7 @@ function uploadImage(url, params, cfg) {
'Content-Type': 'application/json;charset=UTF-8'
}
wx.showLoading()
console.log('params.file',params)
console.log('params.file', params)
wx.uploadFile({
url: config.domain + url,
filePath: params.file,
......@@ -122,18 +123,18 @@ function uploadImage(url, params, cfg) {
cfg.erc(res)
} else if (res.data.msg) {
if (res.data.msg instanceof Array) {
wx.showToast({title: res.data.msg[0]})
wx.showToast({ title: res.data.msg[0] })
} else {
wx.showToast({title: res.data.msg})
wx.showToast({ title: res.data.msg })
}
} else {
wx.showToast({title: '请求失败,请重试!'})
wx.showToast({ title: '请求失败,请重试!' })
}
}
},
fail: err => {
wx.hideLoading()
wx.showToast({title: '图片上传失败,请重试!'})
wx.showToast({ title: '图片上传失败,请重试!' })
if (cfg.erc) {
cfg.erc(err)
}
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment