var app = getApp();
Page({
data:{
good:[],//商品
goodUrl:'/m.php?g=api&m=wxshop&a=goods&goods_id=',//商品
formData:'',
index:0,
num:1,
buy:{},
orderUrl:'m.php?g=api&m=wxshop&a=send_order',//提交订单
//提示框参数
toast1Hidden:true,
modalHidden: true,
modalHidden2: true,
notice_str: '',
serverSrc:app.globalData.serverUrl,//服务器地址
order:[],
address:{},//默认地址
},
onShow: function () {
var that = this
if(app.globalData.order_k){
//发送请求获取订单
wx.request({
url: 'https://www.520hhy.cn/m.php?g=api&m=wxshop&a=my_order&limit=10&',
data: {
sess_id:wx.getStorageSync(
'sess_id'
),
type:"no_handle"
},
method: 'GET', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
// header: {}, // 设置请求的 header
success: function(res){
// 遍历所有订单,通过order_id获取当前订单
console.log(res.data.data)
var _data=res.data.data;
for(var i=0;i<_data.length;i++){
console.log(_data[i])
if(_data[i].order_id==app.globalData.order_id){
app.globalData.choose_address={
address:_data[i].address,
phone:_data[i].phone,
receiver: _data[i].user,
num:_data[i].goods_num*1,
}
}
}
that.setData({
num:app.globalData.choose_address.num,
address:app.globalData.choose_address//选择的地址代替更改默认地址
})
app.globalData.order_k=false;//改为默认
},
fail: function() {
// fail
},
complete: function() {
// complete
}
})
}else{
that.setData({
address:app.globalData.choose_address//选择的地址代替更改默认地址
})
}
console.log(app.globalData.choose_address)
//获取商品信息
console.log(app.globalData.requestId+"---"+app.globalData.choose_address)
wx.request({
url: app.globalData.serverUrl+that.data.goodUrl+app.globalData.requestId, //详情页数据
header: {
'content-type': 'application/json'
},
success: function(res) {
console.log(res.data)
that.setData({
good:res.data.data
})
console.log(that.data.good)
}
})
//获取订单信息
wx.request({
url: app.globalData.serverUrl+'m.php?g=api&m=wxshop&a=my_order&limit=10', //购物车
header: {
'content-type': 'application/json'
},
data:{
sess_id:wx.getStorageSync(
'sess_id'
)
},
success: function(res) {
console.log(res.data)
}
})
//调用应用实例的方法获取全局数据
app.getUserInfo(function(userInfo){
//更新数据
that.setData({
userInfo:userInfo
})
})
},
// 数量增加
add:function(){
var nums=this.data.num
nums+=1
this.setData({
num:nums
})
// let num=this.data.num
// num+=1
},
sub:function(){
var nums=this.data.num
nums-=1;
if(nums==0){
this.setData({
toast1Hidden:false,
notice_str:'数量不能小于1',
})
nums=1
}
this.setData({
num:nums
})
// let num=this.data.num
// num+=1
},
toast1Change:function(e){
this.setData({toast1Hidden:true});
},
//弹出确认框
modalTap: function(e) {
this.setData({
modalHidden: false
})
},
confirm_one: function(e) {
console.log(e);
var that=this
//确认---->提交订单,发送到服务器
wx.request({
url:app.globalData.serverUrl+that.data.orderUrl+'&sess_id='+wx.getStorageSync('sess_id'),
data:{
phone:that.data.formData.number,
user:that.data.formData.name,
address:that.data.formData.address,
goods_id:app.globalData.requestId,
num:that.data.num,
extra:that.data.formData.txt
},
method: 'POST',
header: {
'Content-Type': "application/x-www-form-urlencoded"
},
success: function(res) {
console.log("提交订单成功")
console.log(res.data)
}
})
this.setData({
modalHidden: true,
toast1Hidden:false,
notice_str: '提交成功!'
});
},
cancel_one: function(e) {
console.log(e);
this.setData({
modalHidden: true,
toast1Hidden:false,
notice_str: '取消成功'
});
},
//跳转个人中心
goPer:function(){
wx.navigateTo({
url: '../personal/personal',
success: function(res){
// success
}
})
},
//去选择地址
goAdr:function(){
wx.navigateTo({
url: '../address/address',
success: function(res){
// success
},
fail: function() {
// fail
},
complete: function() {
// complete
}
})
},
//弹出提示框
// modalTap2: function(e) {
// this.setData({
// modalHidden2: false
// })
// },
// modalChange2: function(e) {
// this.setData({
// modalHidden2: true
// })
// },
//提交订单
formSubmit:function(e){
var formData = e.detail.value
var that=this
that.setData({
formData:formData
})
console.log(typeof formData.number)
console.log(that.data.num+"----"+formData)
// app.requestId
if(formData.number=="" || formData.name=="" || formData.address==""){//电话、姓名、地址有一个为空
that.setData({
toast1Hidden:false,
notice_str:'请填写完整表单信息',
})
}else{//电话、姓名、地址都不为空
//弹出提示框
that.modalTap();
}
},
// formReset: function() {
// console.log('form发生了reset事件');
// this.modalTap2();
// },
// bindPickerChange: function(e) {
// console.log('picker发送选择改变,携带值为', e.detail.value)
// this.setData({
// index: e.detail.value
// })
// },
// onLoad:function(options){
// // 页面初始化 options为页面跳转所带来的参数
// },
back:function(){
wx.navigateBack({
delta: 2
})
},
//分享
onShareAppMessage: function () {
return {
title: '商城',
desc: '订单',
path: 'pages/order/order'
}
}
})
没有合适的资源?快使用搜索试试~ 我知道了~
微信小程序之学习用商品详情购物车制作.毕业设计
共55个文件
png:14个
js:12个
wxss:10个
需积分: 13 0 下载量 144 浏览量
2023-02-10
19:55:34
上传
评论
收藏 40KB RAR 举报
温馨提示
微信小程序之学习用商品详情购物车制作.毕业设计
资源推荐
资源详情
资源评论
收起资源包目录
学习用商品详情购物车.rar (55个子文件)
学习用商品详情购物车
wxapp_zczh-master_code
pages
personal
personal.wxss 746B
personal.wxml 922B
personal.json 74B
personal.js 1KB
index
index.wxml 914B
index.js 4KB
index.json 32B
index.wxss 619B
order
order.wxml 3KB
order.json 39B
order.js 7KB
order.wxss 1KB
bigpic
bigpic.wxml 422B
bigpic.js 1KB
bigpic.wxss 71B
bigpic.json 74B
orderList
orderList.json 42B
orderList.wxml 1KB
orderList.js 3KB
orderList.wxss 800B
.js 0B
goods
goods.wxss 2KB
goods.wxml 1KB
goods.json 74B
goods.js 2KB
editAddress
editAddress.wxml 1KB
editAddress.json 42B
editAddress.wxss 477B
editAddress.js 3KB
logs
logs.json 54B
logs.js 266B
logs.wxml 188B
logs.wxss 106B
address
address.wxml 925B
address.js 5KB
address.json 74B
address.wxss 766B
app.json 461B
app.js 2KB
image
payed.png 811B
edit.png 1KB
pay.png 1KB
payed1.png 787B
home (1).png 1KB
home.png 2KB
dingzhi.png 1KB
go.png 372B
per.png 1KB
add.png 2KB
del.png 795B
pay1.png 1KB
i_home.png 1KB
pay2.png 1KB
utils
util.js 460B
app.wxss 341B
共 55 条
- 1
资源评论
程序员奇奇
- 粉丝: 3w+
- 资源: 294
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功