作者 zhangwei

zw

... ... @@ -32,118 +32,116 @@ App({
}
}
})
},
//自动更新版本
const updateManager = wx.getUpdateManager()
updateManager.onCheckForUpdate(function (res) {
// 请求完新版本信息的回调
})
updateManager.onUpdateReady(function () {
wx.showModal({
title: '更新提示',
content: '新版本已经准备好,是否重启应用?',
success: function (res) {
if (res.confirm) {
// 新的版本已经下载好,调用 applyUpdate 应用新版本并重启
updateManager.applyUpdate()
}
}
})
})
updateManager.onUpdateFailed(function () {
// 新的版本下载失败
wx.showModal({
title: '更新提示',
content: '新版本下载失败',
showCancel: false
})
})
},
/**
* 自定义post函数,返回Promise
* +-------------------
* @param {String} url 接口网址
* @param {arrayObject} data 要传的数组对象 like: {name: 'name', age: 32}
* +-------------------
* @return {Promise} promise 返回promise供后续操作
*/
// url:接口地址 data:接口数据 header:请求头
post: function (url, data, headerParams) {
/**
* 自定义post函数,返回Promise
* +-------------------
* @param {String} url 接口网址
* @param {arrayObject} data 要传的数组对象 like: {name: 'name', age: 32}
* +-------------------
* @return {Promise} promise 返回promise供后续操作
*/
// wx.showLoading({
// title: '加载中',
// })
wx.showNavigationBarLoading()
wx.showLoading({
title: '加载中',
})
var promise = new Promise((resolve, reject) => {
//init
let that = this;
let postData = data;
let baseUrl = 'http://grouppay.w.bronet.cn/api/';
// let baseUrl = 'http://192.168.1.15/public';
// postData.signature = that.makeSign(postData);
//网络请求
let header = {
'content-type': 'application/x-www-form-urlencoded',
'XX-Token': '123123'
'content-type': 'application/x-www-form-urlencoded'
}
// console.log(baseUrl/ + url)
header = Object.assign(header, headerParams)
wx.request({
url: baseUrl + url,
data: postData,
method: 'POST',
header: header,
success: function (res) { //返回取得的数据
// console.log(res)
success: function (res) {//返回取得的数据
if (res.data.code == '20000') {
resolve(res.data);
} else if (res.data.code == '10001') {//用户未
} else if (res.data.code == '40000') {
wx.showModal({
title: '提示',
content: res.data.msg,
showCancel: false,
success: function (res) {
}
resolve(res.data.data);
} else if(res.data.code == '30000') {
resolve(res.data.data);
} else if (res.data.code == '40000') {//返回错误提示信息
wx.showToast({
title: res.data.msg,
icon: 'none'
})
} else if (res.data.code == '40005') {
} else if (res.data.code == '40001') {//返回错误提示信息
wx.showModal({
title: '提示',
content: res.data.msg,
content: '登录已过期请重新登录!',
showCancel: false,
success: function (res) {
if (res.confirm) {
wx.removeStorageSync('token');
wx.navigateTo({
// url: '/pages/startRecord/startRecord',
})
}
}
})
} else if (res.data.code == '40006') {
} else if (res.data.code == '40002') {
console.log(res)
// wx.showModal({
// title: '提示',
// // content: res.data.msg,
// showCancel: false,
// success: function (res) { }
// })
} else if (res.data.code == '40003') {
// 初始化用户信息判断
let usetrInfoType = {
hasUserInfo: false
}
resolve(usetrInfoType);
// wx.showModal({
// title: '提示',
// content: res.data.msg,
// showCancel: false
// })
} else {
wx.showModal({
title: '提示',
content: res.data.msg,
showCancel: false,
})
console.log(res)
// wx.showModal({
// title: '提示',
// // content: res.data.msg,
// showCancel: false
// })
reject(res.data)
}
wx.hideLoading()
wx.hideNavigationBarLoading()
setTimeout(function () {
wx.hideLoading()
wx.hideNavigationBarLoading()
}, 600)
},
fail: function (e) {
console.log(e)
reject('网络出错');
// wx.hideLoading()
wx.hideNavigationBarLoading()
}
})
});
return promise;
},
globalData: {
userInfo: null
userInfo: null,
baseUrl: '../../img/',
artid: null
}
})
\ No newline at end of file
})
... ...
... ... @@ -18,7 +18,7 @@
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTitleText": "团购商城",
"navigationBarTextStyle": "black"
},
"tabBar": {
... ...
// pages/homeindex/homeindex.js
const app=getApp()
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
url:''
banner: [],
shop_class: [],
middle:'',
shop:[]
},
// 跳转页面
btn_name() {
wx.navigateTo({
url: '/pages/homeindex/search/search',
})
},
get_info() {
let that = this
let url = app.interface.index;
let header = {
'XX-Device-Type': 'wxapp',
'XX-Token': wx.getStorageSync('token')
}
app.post(url, {}, header).then((res) => {
console.log(res)
that.setData({
banner: res.data.banner,
shop_class: res.data.shop_class,
middle: res.data.middle,
shop:res.data.shop
})
}).catch((errMsg) => {})
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
url: app.globalData.baseUrl
})
console.log(this.data.url)
onLoad: function(options) {
let that = this
that.get_info()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
onShareAppMessage: function() {
}
})
\ No newline at end of file
... ...
<!--pages/homeindex/homeindex.wxml-->
<text>pages/homeindex/homeindex.wxml</text>
... ...
/* pages/homeindex/homeindex.wxss */
\ No newline at end of file
// pages/homeindex/search/search.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
recommend: [],
history: [],
keyword: ''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let that = this
that.get_info()
},
get_info() {
let that = this
// 接口地址
let url = app.interface.history
let header = {
'XX-Device-Type': 'wxapp',
'XX-Token': wx.getStorageSync('token')
}
app.post(url, {},header).then((res) => {
console.log(res)
that.setData({
recommend: res.data.recommend,
history: res.data.history
})
}).catch((errMsg) => {
})
},
// get_info() {
// let that = this
// let url = app.interface.index;
// let header = {
// 'XX-Device-Type': 'wxapp',
// 'XX-Token': wx.getStorageSync('token')
// }
// app.post(url, {}, header).then((res) => {
// console.log(res)
// that.setData({
// banner: res.data.banner,
// shop_class: res.data.shop_class,
// middle: res.data.middle,
// shop: res.data.shop
// })
// }).catch((errMsg) => { })
// },
info(){
let that = this
// 接口地址
let url = app.interface.shopPage
app.post(url, {
page: 1,
keyword: that.data.keyword
}).then((res) => {
console.log(res)
that.setData({
})
}).catch((errMsg) => {
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
<!--pages/homeindex/search/search.wxml-->
<!-- <text>pages/homeindex/search/search.wxml</text> -->
<view class='search'>
<view class='search_inp'>
<input type='text' placeholder='请输入商品名称'></input>
<image src='../../../img/search.png'></image>
</view>
<view class='search_txt' bindtap='info'>
搜索
</view>
</view>
<view class='Popular'>
<view class='Popular_title'>
<text>热门搜索</text>
<image src='../../../img/zuire@3x.png'></image>
</view>
<view class='Popular_list' >
<view class='Popular_item' wx:for='{{recommend}}' wx:key>
{{recommend[index]}}
</view>
</view>
<view class='History'>
<view class='History_title'>历史搜索</view>
<view class='History_list'>
<view class='History_item' wx:for='{{history}}' wx:key>{{history[index]}}</view>
</view>
</view>
</view>
\ No newline at end of file
... ...
... ... @@ -4,89 +4,66 @@ const app = getApp()
Page({
data: {
motto: 'Hello World',
userInfo: {},
hasUserInfo: false,
canIUse: wx.canIUse('button.open-type.getUserInfo')
},
//事件处理函数
bindViewTap: function() {
wx.navigateTo({
url: '../logs/logs'
})
session_key:'',
openid:''
},
start(e) {
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.getLoginFun();
},
// 获取session_key
getLoginFun() {
let that = this;
console.log(e)
// app.globalData.userInfo = e.detail.userInfo
wx.login({
success: (res) => {
console.log(res)
wx.switchTab({
url: '../homeindex/homeindex',
})
// let url = '/api/portal/common/getToken ';
// let params = {
// code: res.code,
// user_nickname: e.detail.userInfo.nickName,
// avatar: e.detail.userInfo.avatarUrl
// // user_nickname: e.detail.userInfo.nickName,
// // avatar: e.detail.userInfo.avatarUrl //分享进入的需要此参数
// }
// app.post(url, params).then((res) => {
// console.log(res)
// wx.setStorageSync('token', res.token);
// wx.navigateTo({
// url: '../mainindex/mainindex',
// })
// }).catch((errMsg) => {
// // console.log(errMsg)
// })
success: function (s) {
console.log(s);
let url = 'wxapp/public/getSessionKey';
if (s.code) {
var code = s.code;
var param = {
code: s.code
}
app.post(url, param).then((res) => {
console.log(res);
that.setData({
openid: res.data.openid,
session_key: res.data.session_key
})
// res.data = {}
}).catch((errMsg) => {
console.log(errMsg);
})
}
}
});
},
onLoad: function () {
if (app.globalData.userInfo) {
this.setData({
userInfo: app.globalData.userInfo,
hasUserInfo: true
})
} else if (this.data.canIUse){
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
app.userInfoReadyCallback = res => {
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
} else {
// 在没有 open-type=getUserInfo 版本的兼容处理
wx.getUserInfo({
success: res => {
app.globalData.userInfo = res.userInfo
this.setData({
userInfo: res.userInfo,
hasUserInfo: true
})
}
})
// 获取用户信息
getUserInfo(e) {
console.log(e);
let url = "wxapp/public/login";
let data = {
openid: this.data.openid,
session_key: this.data.session_key,
encrypted_data: e.detail.encryptedData,
iv: e.detail.iv,
}
},
getUserInfo: function(e) {
console.log(e)
app.globalData.userInfo = e.detail.userInfo
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
app.post(url, data).then((res) => {
console.log(res);
wx.setStorageSync("token", res.data.token);
wx.switchTab({
url: '../homeindex/homeindex',
})
}).catch((err) => {
console.log(err);
})
}
},
})
... ...
<button open-type="getUserInfo" bindgetuserinfo='start' class="begin">启动小程序</button>
<view class='box'>
<view class='cover'>
<image src="../../images/aicon_23@2x.png"></image>
asdlkjhnaisd
<view class='go'>
<button open-type='getUserInfo' bindgetuserinfo="getUserInfo">立即启动</button>
</view>
</view>
</view>
\ No newline at end of file
... ...
/**index.wxss**/
.userinfo {
display: flex;
flex-direction: column;
align-items: center;
.cover{
position: relative;
height: 100vh;
overflow:hidden;
}
.userinfo-avatar {
width: 128rpx;
height: 128rpx;
margin: 20rpx;
border-radius: 50%;
.cover image{
width:100%;
height:100%;
}
.userinfo-nickname {
color: #aaa;
.go{
position: absolute;
bottom:26.41%;
left:0;
right: 0;
margin: auto;
width:400rpx;
height:80rpx;
border-radius:40rpx;
background: #6EAC3D;
/* border:1rpx solid #434343; */
}
.usermotto {
margin-top: 200px;
.go button{
font-size:30rpx;
color:#fff;
text-align: center;
line-height:80rpx;
display: block;
background:none;
}
\ No newline at end of file
... ...
... ... @@ -28,7 +28,7 @@ Page({
goFirm_order1(e){
wx.navigateTo({
url: '../firm_order1/firm_order1?id=' + e.currentTarget.dataset.id,
url: '../firm_order1/firm_order1?id=' + e.currentTarget.dataset.id + "&&num=" + this.data.num,
})
},
... ...
// pages/kind/firm_order1/firm_order1.js
const app = getApp();
Page({
goFirm_order2: function() {
wx.navigateTo({
url: '../firm_order2/firm_order2',
})
// 点击立即支付
goFirm_order2: function(e) {
},
/**
* 页面的初始数据
... ... @@ -18,13 +17,15 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function(options){
console.log(options.num)
this.setData({
shop_id:options.id
})
console.log(options.id)
this.order()
this.order(options.num)
},
order(){
// 确认订单1数据
order(num){
let that = this;
let url = "home/index/goods";
let header = {
... ... @@ -32,13 +33,13 @@ Page({
"XX-Device-Type": 'wxapp'
}
let params = {
shop_id: that.data.shop_id
// shop_numb:
shop_id: that.data.shop_id,
shop_numb:num
}
app.post(url,params,header).then((res) => {
console.log(res)
that.setData({
order_list:res.shop
order_list:res
})
}).catch((err) => {
console.log(err)
... ...
... ... @@ -15,7 +15,7 @@
<view class='name'>{{order_list.name}}</view>
<view class='phone'>{{order_list.mobile}}</view>
</view>
<view class='address'></view>
<view class='address'>{{order_list.address}}</view>
</view>
<image class='o_right' src='../../../img/right_1.png'></image>
</view>
... ... @@ -35,58 +35,20 @@
<view class='goods_detail'>
<view class='goods_detail_pic'>
<view class='detail_pic2'>
<image src='../../../img/douyao.png'></image>
<image src='{{order_list.shop.thumb}}'></image>
</view>
<view class='detail_pic_txt'>距结束2时22分</view>
<view class='detail_pic_txt'>{{order_list.shop.end_time}}</view>
</view>
<view class='detail_txt'>
<view class='txt1'>
<view class='txt1_name'>纯进口有机菜花</view>
<view class='txt1_price'>¥52.00</view>
<view class='txt1_name'>{{order_list.shop.name}}</view>
<view class='txt1_price'>¥{{order_list.shop.money_sale}}</view>
</view>
<view class='txt2'>
<progress percent="42" show-info color="#B5DE96" border-radius="8" font-size="24rpx" stroke-width="16rpx" />
<view class='order'>x4</view>
<view class='order'>x{{order_list.shop_numb}}</view>
</view>
<view class='txt3'>已拼300份,目标500份</view>
</view>
</view>
<view class='goods_detail'>
<view class='goods_detail_pic'>
<view class='detail_pic2'>
<image src='../../../img/douyao.png'></image>
</view>
<view class='detail_pic_txt'>距结束2时22分</view>
</view>
<view class='detail_txt'>
<view class='txt1'>
<view class='txt1_name'>纯进口有机菜花</view>
<view class='txt1_price'>¥52.00</view>
</view>
<view class='txt2'>
<progress percent="42" show-info color="#B5DE96" border-radius="8" font-size="24rpx" stroke-width="16rpx" />
<view class='order'>x4</view>
</view>
<view class='txt3'>已拼300份,目标500份</view>
</view>
</view>
<view class='goods_detail'>
<view class='goods_detail_pic'>
<view class='detail_pic2'>
<image src='../../../img/douyao.png'></image>
</view>
<view class='detail_pic_txt'>距结束2时22分</view>
</view>
<view class='detail_txt'>
<view class='txt1'>
<view class='txt1_name'>纯进口有机菜花</view>
<view class='txt1_price'>¥52.00</view>
</view>
<view class='txt2'>
<progress percent="42" show-info color="#B5DE96" border-radius="8" font-size="24rpx" stroke-width="16rpx" />
<view class='order'>x4</view>
</view>
<view class='txt3'>已拼300份,目标500份</view>
<view class='txt3'>已拼{{order_list.shop.numb}}份,目标{{order_list.shop.group}}份</view>
</view>
</view>
<!-- 运费 -->
... ... @@ -98,11 +60,12 @@
<view class='othor'>
<view class='othor1'>
<view class='othor1_name'>订单号</view>
<view class='othor1_con'>2019885878957</view>
<view class='othor1_con'>{{order_list.goods}}</view>
</view>
<view class='othor1'>
<view class='othor1 '>
<view class='othor1_name'>备注信息</view>
<view class='othor1_con'>尽量下午送货,来时电话联系</view>
<textarea maxlength='30' class='othor1_con othor1_con2' placeholder='尽量下午送货,来时电话联系' placeholder-class="placeholderStyle"></textarea>
<view ></view>
</view>
</view>
</view>
... ... @@ -111,10 +74,10 @@
</view>
<view class='footer'>
<view class='footer_in'>
<view class='f_txt1'>共1件商品</view>
<view class='f_txt1'>共{{order_list.shop_numb}}件商品</view>
<view class='f_txt2'>合计:
<text class='f_txt3'>¥52.00</text>
<text class='f_txt3'>¥{{order_list.shop_numb*order_list.shop.money_sale}}</text>
</view>
<view class='f_btn' bindtap='goFirm_order2'>立即支付</view>
<view class='f_btn' bindtap=''>立即支付</view>
</view>
</view>
\ No newline at end of file
... ...
... ... @@ -223,7 +223,6 @@ page {
.othor1 {
display: flex;
align-items: center;
margin-bottom: 16rpx;
}
... ... @@ -233,15 +232,23 @@ page {
font-weight: 400;
color: rgba(51, 51, 51, 1);
}
.othor1_con {
.othor1_con{
font-size: 26rpx;
margin-left: auto;
font-family: PingFang SC;
font-weight: 400;
color: rgba(153, 153, 153, 1);
}
.othor1_con2{
width:330rpx;
height:100rpx;
font-size: 26rpx;
margin-left: auto;
font-family: PingFang SC;
font-weight: 400;
margin-top:6rpx;
color: rgba(153, 153, 153, 1);
}
/* footer */
.footer {
... ...
// pages/kind/firm_order2/firm_order2.js
const app = getApp()
Page({
go_success:function(){
wx.navigateTo({
url: '../success/success',
})
},
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
go_success: function() {
wx.navigateTo({
url: '../success/success',
})
},
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
this.orderFun2()
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
orderFun2(shop_id) {
let that = this;
let url = "";
let header = {
"XX-Token": '123123',
"XX-Device-Type": 'wxapp'
};
let params = {
shop_id: shop_id
};
app.post(url,params,header).then((res) =>{
console.log(res)
})
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
}
})
\ No newline at end of file
... ...
// pages/kind/kind.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
class_id: ''
},
... ... @@ -12,9 +14,32 @@ Page({
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
let that = this
that.get_info()
},
get_info() {
let that = this
// 接口地址
let url = app.interface.shopClass
let header = {
'XX-Device-Type': 'wxapp',
'XX-Token': wx.getStorageSync('token')
}
let params = {
class_id: that.data.class_id
}
app.post(url, params, header).then((res) => {
console.log(res)
that.setData({
shop_class: res.data.shop_class,
shop:res.data.shop
})
}).catch((errMsg) => {
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
... ...
<!--pages/kind/kind.wxml-->
<text>pages/kind/kind.wxml</text>
... ...
/* pages/kind/kind.wxss */
\ No newline at end of file
... ... @@ -92,13 +92,14 @@
"id": 7,
"name": "商品详情",
"pathName": "pages/kind/detail_1/detail_1",
"query": ""
"query": "id=1",
"scene": null
},
{
"id": -1,
"id": 8,
"name": "确认订单",
"pathName": "pages/kind/firm_order1/firm_order1",
"query": "",
"query": "id = 1",
"scene": null
}
]
... ...