Commit eb158458 authored by Menethil's avatar Menethil
Browse files

添加自动更新,部分页面支持下拉刷新

parent 96979025
......@@ -559,7 +559,7 @@ public class WxOrderController {
* 这里微信的短信平台对参数长度有限制,所以将订单号只截取后6位
*
*/
notifyService.notifySmsTemplate(order.getMobile(), NotifyType.PAY_SUCCEED, new String[]{orderSn.substring(8, 14)});
notifyService.notifySmsTemplateSync(order.getMobile(), NotifyType.PAY_SUCCEED, new String[]{orderSn.substring(8, 14)});
return WxPayNotifyResponse.success("处理成功!");
} catch (Exception e) {
......
......@@ -4,6 +4,19 @@ var user = require('./utils/user.js');
App({
onLaunch: function () {
const updateManager = wx.getUpdateManager();
wx.getUpdateManager().onUpdateReady(function () {
wx.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success: function (res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
}
}
})
})
},
onShow: function (options) {
user.checkLogin().then(res => {
......
......@@ -35,10 +35,10 @@
"window": {
"navigationBarBackgroundColor": "#FFFFFF",
"navigationBarTitleText": "litemall小程序商城",
"enablePullDownRefresh": true,
"navigationBarTextStyle": "black",
"backgroundColor": "#FFFFFF",
"backgroundTextStyle": "dark",
"enablePullDownRefresh": false
"backgroundTextStyle": "dark"
},
"tabBar": {
"backgroundColor": "#fafafa",
......
......@@ -6,7 +6,7 @@
// 云平台部署时使用
var WxApiRoot = 'http://122.152.206.172:8082/wx/';
// 云平台上线时使用
// var WxApiRoot = 'https://www.example.com/wx/';
// var WxApiRoot = 'https://www.menethil.com.cn/wx/';
// 以下是图片存储服务器API地址
// 本机开发时使用
......@@ -16,7 +16,7 @@ var WxApiRoot = 'http://122.152.206.172:8082/wx/';
// 云平台部署时使用
var StorageApi = 'http://122.152.206.172:8081/os/storage/create';
// 云平台上线时使用
// var StorageApi = 'https://www.example.com/os/storage/create';
// var StorageApi = 'https://www.menethil.com.cn/os/storage/create';
module.exports = {
IndexUrl: WxApiRoot + 'home/index', //首页数据接口
......@@ -27,6 +27,7 @@ module.exports = {
AuthLoginByAccount: WxApiRoot + 'auth/login', //账号登录
AuthRegister: WxApiRoot + 'auth/register', //账号注册
AuthReset: WxApiRoot + 'auth/reset', //账号密码重置
AuthRegisterCaptcha: WxApiRoot + 'auth/regCaptcha', //验证码
GoodsCount: WxApiRoot + 'goods/count', //统计商品总数
GoodsList: WxApiRoot + 'goods/list', //获得商品列表
......@@ -69,7 +70,7 @@ module.exports = {
AddressSave: WxApiRoot + 'address/save', //保存收货地址
AddressDelete: WxApiRoot + 'address/delete', //保存收货地址
ExpressQuery: WxApiRoot + 'express/query',//物流查询
ExpressQuery: WxApiRoot + 'express/query', //物流查询
RegionList: WxApiRoot + 'region/list', //获取区域列表
......
......@@ -18,15 +18,21 @@ Page({
editCartList: [],
hasLogin: false
},
onLoad: function (options) {
onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数
},
onReady: function () {
onReady: function() {
// 页面渲染完成
},
onShow: function () {
onPullDownRefresh() {
wx.showNavigationBarLoading() //在标题栏中显示加载
this.getCartList();
wx.hideNavigationBarLoading() //完成停止加载
wx.stopPullDownRefresh() //停止下拉刷新
},
onShow: function() {
// 页面显示
if (app.globalData.hasLogin){
if (app.globalData.hasLogin) {
this.getCartList();
}
......@@ -35,18 +41,20 @@ Page({
});
},
onHide: function () {
onHide: function() {
// 页面隐藏
},
onUnload: function () {
onUnload: function() {
// 页面关闭
},
goLogin() {
wx.navigateTo({ url: "/pages/auth/login/login" });
wx.navigateTo({
url: "/pages/auth/login/login"
});
},
getCartList: function () {
getCartList: function() {
let that = this;
util.request(api.CartList).then(function (res) {
util.request(api.CartList).then(function(res) {
if (res.errno === 0) {
that.setData({
cartGoods: res.data.cartList,
......@@ -59,9 +67,9 @@ Page({
}
});
},
isCheckedAll: function () {
isCheckedAll: function() {
//判断购物车商品已全选
return this.data.cartGoods.every(function (element, index, array) {
return this.data.cartGoods.every(function(element, index, array) {
if (element.checked == true) {
return true;
} else {
......@@ -69,20 +77,23 @@ Page({
}
});
},
doCheckedAll: function () {
doCheckedAll: function() {
let checkedAll = this.isCheckedAll()
this.setData({
checkedAllStatus: this.isCheckedAll()
});
},
checkedItem: function (event) {
checkedItem: function(event) {
let itemIndex = event.target.dataset.itemIndex;
let that = this;
let productIds = [];
productIds.push(that.data.cartGoods[itemIndex].productId);
if (!this.data.isEditCart) {
util.request(api.CartChecked, { productIds: productIds, isChecked: that.data.cartGoods[itemIndex].checked ? 0 : 1 }, 'POST').then(function (res) {
util.request(api.CartChecked, {
productIds: productIds,
isChecked: that.data.cartGoods[itemIndex].checked ? 0 : 1
}, 'POST').then(function(res) {
if (res.errno === 0) {
that.setData({
cartGoods: res.data.cartList,
......@@ -96,8 +107,8 @@ Page({
});
} else {
//编辑状态
let tmpCartData = this.data.cartGoods.map(function (element, index, array) {
if (index == itemIndex){
let tmpCartData = this.data.cartGoods.map(function(element, index, array) {
if (index == itemIndex) {
element.checked = !element.checked;
}
......@@ -111,9 +122,9 @@ Page({
});
}
},
getCheckedGoodsCount: function(){
getCheckedGoodsCount: function() {
let checkedGoodsCount = 0;
this.data.cartGoods.forEach(function (v) {
this.data.cartGoods.forEach(function(v) {
if (v.checked === true) {
checkedGoodsCount += v.number;
}
......@@ -121,14 +132,17 @@ Page({
console.log(checkedGoodsCount);
return checkedGoodsCount;
},
checkedAll: function () {
checkedAll: function() {
let that = this;
if (!this.data.isEditCart) {
var productIds = this.data.cartGoods.map(function (v) {
var productIds = this.data.cartGoods.map(function(v) {
return v.productId;
});
util.request(api.CartChecked, { productIds: productIds, isChecked: that.isCheckedAll() ? 0 : 1 }, 'POST').then(function (res) {
util.request(api.CartChecked, {
productIds: productIds,
isChecked: that.isCheckedAll() ? 0 : 1
}, 'POST').then(function(res) {
if (res.errno === 0) {
console.log(res.data);
that.setData({
......@@ -144,7 +158,7 @@ Page({
} else {
//编辑状态
let checkedAllStatus = that.isCheckedAll();
let tmpCartData = this.data.cartGoods.map(function (v) {
let tmpCartData = this.data.cartGoods.map(function(v) {
v.checked = !checkedAllStatus;
return v;
});
......@@ -157,7 +171,7 @@ Page({
}
},
editCart: function () {
editCart: function() {
var that = this;
if (this.data.isEditCart) {
this.getCartList();
......@@ -166,7 +180,7 @@ Page({
});
} else {
//编辑状态
let tmpCartList = this.data.cartGoods.map(function (v) {
let tmpCartList = this.data.cartGoods.map(function(v) {
v.checked = false;
return v;
});
......@@ -180,7 +194,7 @@ Page({
}
},
updateCart: function (productId, goodsId, number, id) {
updateCart: function(productId, goodsId, number, id) {
let that = this;
util.request(api.CartUpdate, {
......@@ -188,14 +202,14 @@ Page({
goodsId: goodsId,
number: number,
id: id
}, 'POST').then(function (res) {
}, 'POST').then(function(res) {
that.setData({
checkedAllStatus: that.isCheckedAll()
});
});
},
cutNumber: function (event) {
cutNumber: function(event) {
let itemIndex = event.target.dataset.itemIndex;
let cartItem = this.data.cartGoods[itemIndex];
......@@ -206,7 +220,7 @@ Page({
});
this.updateCart(cartItem.productId, cartItem.goodsId, number, cartItem.id);
},
addNumber: function (event) {
addNumber: function(event) {
let itemIndex = event.target.dataset.itemIndex;
let cartItem = this.data.cartGoods[itemIndex];
let number = cartItem.number + 1;
......@@ -217,11 +231,11 @@ Page({
this.updateCart(cartItem.productId, cartItem.goodsId, number, cartItem.id);
},
checkoutOrder: function () {
checkoutOrder: function() {
//获取已选择的商品
let that = this;
var checkedGoods = this.data.cartGoods.filter(function (element, index, array) {
var checkedGoods = this.data.cartGoods.filter(function(element, index, array) {
if (element.checked == true) {
return true;
} else {
......@@ -239,15 +253,14 @@ Page({
wx.navigateTo({
url: '../shopping/checkout/checkout'
})
} catch (e) {
}
} catch (e) {}
},
deleteCart: function () {
deleteCart: function() {
//获取已选择的商品
let that = this;
let productIds = this.data.cartGoods.filter(function (element, index, array) {
let productIds = this.data.cartGoods.filter(function(element, index, array) {
if (element.checked == true) {
return true;
} else {
......@@ -259,7 +272,7 @@ Page({
return false;
}
productIds = productIds.map(function (element, index, array) {
productIds = productIds.map(function(element, index, array) {
if (element.checked == true) {
return element.productId;
}
......@@ -268,7 +281,7 @@ Page({
util.request(api.CartDelete, {
productIds: productIds
}, 'POST').then(function (res) {
}, 'POST').then(function(res) {
if (res.errno === 0) {
console.log(res.data);
let cartList = res.data.cartList.map(v => {
......
......@@ -11,16 +11,22 @@ Page({
goodsCount: 0,
scrollHeight: 0
},
onLoad: function (options) {
onLoad: function(options) {
this.getCatalog();
},
getCatalog: function () {
onPullDownRefresh() {
wx.showNavigationBarLoading() //在标题栏中显示加载
this.getCatalog();
wx.hideNavigationBarLoading() //完成停止加载
wx.stopPullDownRefresh() //停止下拉刷新
},
getCatalog: function() {
//CatalogList
let that = this;
wx.showLoading({
title: '加载中...',
});
util.request(api.CatalogList).then(function (res) {
util.request(api.CatalogList).then(function(res) {
that.setData({
categoryList: res.data.categoryList,
currentCategory: res.data.currentCategory,
......@@ -28,45 +34,47 @@ Page({
});
wx.hideLoading();
});
util.request(api.GoodsCount).then(function (res) {
util.request(api.GoodsCount).then(function(res) {
that.setData({
goodsCount: res.data.goodsCount
});
});
},
getCurrentCategory: function (id) {
getCurrentCategory: function(id) {
let that = this;
util.request(api.CatalogCurrent, { id: id })
.then(function (res) {
util.request(api.CatalogCurrent, {
id: id
})
.then(function(res) {
that.setData({
currentCategory: res.data.currentCategory,
currentSubCategoryList: res.data.currentSubCategory
});
});
},
onReady: function () {
onReady: function() {
// 页面渲染完成
},
onShow: function () {
onShow: function() {
// 页面显示
},
onHide: function () {
onHide: function() {
// 页面隐藏
},
onUnload: function () {
onUnload: function() {
// 页面关闭
},
getList: function () {
getList: function() {
var that = this;
util.request(api.ApiRootUrl + 'api/catalog/' + that.data.currentCategory.catId)
.then(function (res) {
.then(function(res) {
that.setData({
categoryList: res.data,
});
});
},
switchCate: function (event) {
switchCate: function(event) {
var that = this;
var currentTarget = event.currentTarget;
if (this.data.currentCategory.id == event.currentTarget.dataset.id) {
......
......@@ -27,6 +27,14 @@ Page({
collectImage: '/static/images/icon_collect.png',
soldout: false
},
onPullDownRefresh() {
wx.showNavigationBarLoading() //在标题栏中显示加载
this.getGoodsInfo();
wx.hideNavigationBarLoading() //完成停止加载
wx.stopPullDownRefresh() //停止下拉刷新
},
getGoodsInfo: function() {
let that = this;
util.request(api.GoodsDetail, {
......
......@@ -14,7 +14,7 @@ Page({
banner: [],
channel: []
},
onShareAppMessage: function () {
onShareAppMessage: function() {
return {
title: 'litemall小程序商场',
desc: '开源微信小程序商城',
......@@ -22,9 +22,16 @@ Page({
}
},
getIndexData: function () {
onPullDownRefresh() {
wx.showNavigationBarLoading() //在标题栏中显示加载
this.getIndexData();
wx.hideNavigationBarLoading() //完成停止加载
wx.stopPullDownRefresh() //停止下拉刷新
},
getIndexData: function() {
let that = this;
util.request(api.IndexUrl).then(function (res) {
util.request(api.IndexUrl).then(function(res) {
if (res.errno === 0) {
that.setData({
newGoods: res.data.newGoodsList,
......@@ -38,19 +45,19 @@ Page({
}
});
},
onLoad: function (options) {
onLoad: function(options) {
this.getIndexData();
},
onReady: function () {
onReady: function() {
// 页面渲染完成
},
onShow: function () {
onShow: function() {
// 页面显示
},
onHide: function () {
onHide: function() {
// 页面隐藏
},
onUnload: function () {
onUnload: function() {
// 页面关闭
},
})
\ No newline at end of file
{
"backgroundColor": "#f4f4f4",
"navigationBarTitleText": "个人中心"
"navigationBarTitleText": "个人中心",
"enablePullDownRefresh": false
}
\ No newline at end of file
......@@ -2,16 +2,26 @@ var util = require('../../../utils/util.js');
var api = require('../../../config/api.js');
Page({
data:{
data: {
orderList: [],
showType: 0
},
onLoad:function(options){
onLoad: function(options) {
// 页面初始化 options为页面跳转所带来的参数
},
getOrderList(){
onPullDownRefresh() {
wx.showNavigationBarLoading() //在标题栏中显示加载
this.getOrderList();
wx.hideNavigationBarLoading() //完成停止加载
wx.stopPullDownRefresh() //停止下拉刷新
},
getOrderList() {
let that = this;
util.request(api.OrderList, { showType: that.data.showType}).then(function (res) {
util.request(api.OrderList, {
showType: that.data.showType
}).then(function(res) {
if (res.errno === 0) {
console.log(res.data);
that.setData({
......@@ -20,24 +30,24 @@ Page({
}
});
},
switchTab: function (event) {
switchTab: function(event) {
let showType = event.currentTarget.dataset.index;
this.setData({
showType: showType
});
this.getOrderList();
},
onReady:function(){
onReady: function() {
// 页面渲染完成
},
onShow:function(){
onShow: function() {
// 页面显示
this.getOrderList();
},
onHide:function(){
onHide: function() {
// 页面隐藏
},
onUnload:function(){
onUnload: function() {
// 页面关闭
}
})
\ No newline at end of file
......@@ -28,7 +28,7 @@
"list": []
},
"miniprogram": {
"current": 33,
"current": 32,
"list": [
{
"id": -1,
......@@ -219,7 +219,13 @@
{
"id": -1,
"name": "关于",
"pathName": "pages/about/about"
"pathName": "pages/about/about",
"query": ""
},
{
"id": -1,
"name": "测试更新",
"pathName": "pages/index/index"
}
]
}
......
Supports Markdown
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