作者 lihongjuan

1

正在显示 76 个修改的文件 包含 4591 行增加0 行删除

要显示太多修改。

为保证性能只显示 76 of 76+ 个文件。

//app.js
App({
onLaunch: function () {
// 展示本地存储能力
var logs = wx.getStorageSync('logs') || []
logs.unshift(Date.now())
wx.setStorageSync('logs', logs)
// 登录
wx.login({
success: res => {
// 发送 res.code 到后台换取 openId, sessionKey, unionId
}
})
// 获取用户信息
wx.getSetting({
success: res => {
if (res.authSetting['scope.userInfo']) {
// 已经授权,可以直接调用 getUserInfo 获取头像昵称,不会弹框
wx.getUserInfo({
success: res => {
// 可以将 res 发送给后台解码出 unionId
this.globalData.userInfo = res.userInfo
// 由于 getUserInfo 是网络请求,可能会在 Page.onLoad 之后才返回
// 所以此处加入 callback 以防止这种情况
if (this.userInfoReadyCallback) {
this.userInfoReadyCallback(res)
}
}
})
}
}
})
},
//封装公共接口
post: function (url, data, headerParams) {
wx.showNavigationBarLoading()
var promise = new Promise((resolve, reject) => {
//init
let that = this;
let postData = data;
let baseUrl = 'https://biology.w.broing.cn/api/';
//网络请求
let header = {
// 'XX-Device-Type': 'wxapp',
'token': wx.getStorageSync("token") || ''
}
header = Object.assign(header, headerParams)
//网络请求
wx.request({
url: baseUrl + url,
data: postData,
method: headerParams,
header: header,
success: function (res) { //返回取得的数据
if (res.data.code == '1') {
resolve(res.data.data);
} else if (res.data.code == '201') {
resolve(res.data);
} else {
// wx.showToast({
// title: res.data.msg,
// duration: 1200,
// icon: 'none'
// })
reject(res)
}
// else if (res.data.code == '42002') {
// }
// setTimeout(function () {
// wx.hideNavigationBarLoading()
// }, 600)
},
fail: function (e) {
reject('网络出错');
// wx.hideLoading()
wx.hideNavigationBarLoading()
},
complete: function () {
wx.hideNavigationBarLoading()
},
})
});
return promise;
},
globalData: {
userInfo: null
}
})
\ No newline at end of file
... ...
{
"pages": [
"pages/sousuo/sousuo",
"pages/login/login",
"pages/seemore/seemore",
"pages/orderdetail/orderdetail",
"pages/myorder/myorder",
"pages/fapiaoxinxi/fapiaoxinxi",
"pages/gouwuche/gouwuche",
"pages/addkehu/addkehu",
"pages/mykehu/mykehu",
"pages/gouwucart/gouwucart",
"pages/mine/mine",
"pages/index/index",
"pages/logs/logs"
],
"window": {
"backgroundTextStyle": "light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "",
"navigationBarTextStyle": "black"
},
"sitemapLocation": "sitemap.json",
"tabBar": {
"selectedColor": "#2781FB",
"list": [
{
"pagePath": "pages/sousuo/sousuo",
"text": "搜索",
"selectedColor": "#2781FB",
"iconPath": "img/sou.png",
"selectedIconPath": "img/souactive.png"
},
{
"pagePath": "pages/mine/mine",
"text": "我的",
"selectedColor": "#2781FB",
"iconPath": "img/mine.png",
"selectedIconPath": "img/mineactive.png"
}
]
}
}
\ No newline at end of file
... ...
/**app.wxss**/
.container {
height: 100%;
display: flex;
flex-direction: column;
align-items: center;
justify-content: space-between;
padding: 200rpx 0;
box-sizing: border-box;
}
.register {
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 5;
}
image{
width:100%;
height:100%;
}
.nodata{
color:#999;
font-size: 30rpx;
text-align: center;
margin-top:20rpx;
}
.cartkongimg{
width:399rpx;
height:491rpx;
font-size: 0;
margin:179rpx auto 0;
}
.konggou{
color:#141414;
font-size: 32rpx;
text-align: center;
margin-top:57rpx;
}
\ No newline at end of file
... ...

339 字节

183 字节

897 字节

// pages/addkehu/addkehu.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
selshow: true,
region: [],
kindtype: 0,
province_id: '',
city_id: '',
region_id: '',
address: '',
is_default: 0,
reginname: '',
customer_name: '',
shouhuoname: '',
mobile: '',
address: '',
type: '',
invoice: '',
number: '',
editype: '',
editid: '',
lianxiname: '',
diquselect:''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
// this.setData({
// province_id: '110000',
// city_id: '110100',
// region_id: '110106',
// reginname: this.data.region[0] + "-" + this.data.region[1] + "-" + this.data.region[2]
// })
if (options.editype != undefined) {
this.setData({
editype: options.editype,
editid: options.id
})
this.getkehudetail()
}
},
//获取用户详情页
getkehudetail() {
let url = 'user/customerDetail';
let param = {
customer_id: this.data.editid
}
app.post(url, param, 'get').then((res) => {
console.log(res);
if (res.region!=''){
let newregion = res.region;
newregion = newregion.split("-")
this.setData({
diquselect: newregion[0] + newregion[1] + newregion[2]
})
}else{
this.setData({
diquselect:''
})
}
this.setData({
customer_name: res.customer_name,
mobile: res.mobile,
province_id: res.province_id,
city_id: res.city_id,
region_id: res.area_id,
address: res.address,
kindtype: res.type,
invoice: res.invoice,
number: res.number,
region: res.region.split("-"),
reginname: res.region,
is_default: res.is_default,
shouhuoname: res.receive_name,
lianxiname: res.contact_name,
})
if (res.is_default == 0) {
this.setData({
selshow: true
})
} else {
this.setData({
selshow: false
})
}
console.log(this.data.selshow)
}).catch((err) => {
})
},
//选择省市区
bindRegionChange: function(e) {
console.log(e)
console.log('picker发送选择改变,携带值为', e.detail.value)
this.setData({
region: e.detail.value,
province_id: e.detail.code[0],
city_id: e.detail.code[1],
region_id: e.detail.code[2],
reginname: e.detail.value[0] + '-' + e.detail.value[1] + '-' + e.detail.value[2],
diquselect: e.detail.value[0] + e.detail.value[1] + e.detail.value[2]
})
},
xuanopen() {
this.setData({
selshow: !this.data.selshow
})
if (this.data.selshow == true) {
this.setData({
is_default: 0
})
} else {
this.setData({
is_default: 1
})
}
console.log(this.data.is_default)
},
//输入客户名称
enterkehu(e) {
this.setData({
customer_name: e.detail.value
})
},
//输入联系人
enterlianxi(e) {
this.setData({
lianxiname: e.detail.value
})
},
//输入收货人
entershouhuo(e) {
this.setData({
shouhuoname: e.detail.value
})
},
//输入客户手机号
enterphone(e) {
this.setData({
mobile: e.detail.value
})
},
// 选择发票类型
selectkind(e) {
this.setData({
kindtype: e.currentTarget.dataset.type
})
},
//输入详细地址
enteraddress(e) {
this.setData({
address: e.detail.value
})
},
//输入发票抬头
fapiaohead(e) {
this.setData({
invoice: e.detail.value
})
console.log(this.data.invoice)
},
//税号
shuihao(e) {
this.setData({
number: e.detail.value
})
},
//添加新用户
quding() {
if (this.data.customer_name == '') {
wx.showToast({
title: '请输入客户名称',
icon: "none"
})
return false
}
if (this.data.shouhuoname==''){
wx.showToast({
title: '请输入收货人',
icon: "none"
})
return false
}
// if(this.data.lianxiname==''){
// wx.showToast({
// title: '请输入联系人',
// icon: "none"
// })
// return false
// }
// if (this.data.mobile == '') {
// wx.showToast({
// title: '请输入手机号',
// icon: "none"
// })
// return false
// }
if (this.data.mobile != '') {
let reg = reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
if (!reg.test(this.data.mobile)) {
wx.showToast({
title: '请输入正确的手机号',
icon: "none"
})
return false
}
}
// if(this.data.address==''){
// wx.showToast({
// title: '请输入详细地址',
// icon:"none"
// })
// return false
// }
// if (this.data.invoice==''){
// wx.showToast({
// title: '请输入发票抬头',
// icon:'none'
// })
// return false
// }
// if (this.data.number==''){
// wx.showToast({
// title: '请输入税号',
// icon:'none'
// })
// return false
// }
let url = 'user/addCustomer';
let param = {
customer_name: this.data.customer_name,
receive_name: this.data.shouhuoname,
contact_name: this.data.lianxiname,
mobile: this.data.mobile,
province_id: this.data.province_id,
city_id: this.data.city_id,
area_id: this.data.region_id,
region: this.data.reginname,
address: this.data.address,
type: this.data.kindtype,
invoice: this.data.invoice,
number: this.data.number,
is_default: this.data.is_default
}
app.post(url, param, 'post').then((res) => {
console.log(res);
wx.showToast({
title: '添加客户成功',
icon: 'none'
})
setTimeout(function() {
wx.navigateBack({
checked: true
})
}, 1500)
}).catch((err) => {
console.log(err)
wx.showToast({
title: err.data.msg,
icon: "none"
})
})
},
//编辑客户
editqueding() {
if (this.data.customer_name == '') {
wx.showToast({
title: '请输入客户名称',
icon: "none"
})
return false
}
if (this.data.shouhuoname == '') {
wx.showToast({
title: '请输入收货人',
icon: "none"
})
return false
}
// if (this.data.mobile == '') {
// wx.showToast({
// title: '请输入手机号',
// icon: "none"
// })
// return false
// }
if (this.data.mobile!=''){
let reg = reg = /^[1][3,4,5,6,7,8,9][0-9]{9}$/;
if (!reg.test(this.data.mobile)) {
wx.showToast({
title: '请输入正确的手机号',
icon: "none"
})
return false
}
}
// if (this.data.address == '') {
// wx.showToast({
// title: '请输入详细地址',
// icon: "none"
// })
// return false
// }
// if (this.data.invoice == '') {
// wx.showToast({
// title: '请输入发票抬头',
// icon: 'none'
// })
// return false
// }
// if (this.data.number == '') {
// wx.showToast({
// title: '请输入税号',
// icon: 'none'
// })
// return false
// }
let url = 'user/editCustomer';
let param = {
id: this.data.editid,
customer_name: this.data.customer_name,
receive_name: this.data.shouhuoname,
contact_name: this.data.lianxiname,
mobile: this.data.mobile,
province_id: this.data.province_id,
city_id: this.data.city_id,
area_id: this.data.region_id,
region: this.data.reginname,
address: this.data.address,
type: this.data.kindtype,
invoice: this.data.invoice,
number: this.data.number,
is_default: this.data.is_default
}
app.post(url, param, 'post').then((res) => {
console.log(res);
wx.showToast({
title: '编辑客户成功',
icon: 'none'
})
setTimeout(function() {
wx.navigateBack({
checked: true
})
}, 1500)
}).catch((err) => {
console.log(err)
wx.showToast({
title: err.data.msg,
icon: "none"
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
}
})
\ No newline at end of file
... ...
{
"usingComponents": {}
}
\ No newline at end of file
... ...
<view class="tianjiakehu">添加客户</view>
<view class="kehubox">
<view class="kehutian">
<view class="fapiaotai ming">
<text class="kehuact">客户名称</text>
</view>
<view class="fapiaotaienter ming">
<input placeholder='请输入客户名称' placeholder-class='shurufa' bindinput="enterkehu" value="{{customer_name}}" />
</view>
</view>
<view class="kehutian">
<view class="fapiaotai ming">
<text class="kehuact">收货人</text>
</view>
<view class="fapiaotaienter ming">
<input placeholder='请输入收货人' placeholder-class='shurufa' bindinput="entershouhuo" value="{{shouhuoname}}" />
</view>
</view>
<view class="kehutian">
<view class="fapiaotai ming">联系人</view>
<view class="fapiaotaienter ming">
<input placeholder='请输入联系人' placeholder-class='shurufa' bindinput="enterlianxi" value="{{lianxiname}}" />
</view>
</view>
<view class="kehutian">
<view class="fapiaotai ming">手机号</view>
<view class="fapiaotaienter ming">
<input placeholder='请输入手机号' placeholder-class='shurufa' bindinput="enterphone" type="number" value="{{mobile}}" />
</view>
</view>
<!-- <view class="kehuitem">
<input placeholder='客户名称' />
</view> -->
<view class="kehuitem diquitem">
<view class="diqusel">地区选择</view>
<picker mode="region" bindchange="bindRegionChange" value="{{region}}" custom-item="{{customItem}}">
<view class="diquright">
<view class="selcity">
<view class="selectdiqu">
{{diquselect}}
<!-- {{region[0]}}{{region[1]}}{{region[2]}} -->
</view>
<view class="selimg">
<image src="/img/xiasanjiao.png"></image>
</view>
</view>
<!-- <view class="quan">
<view class="all">全部</view>
<view class="selimg">
<image src="/img/xiasanjiao.png"></image>
</view>
</view> -->
</view>
</picker>
</view>
<view class="kehutian">
<view class="fapiaotai ming">详细地址</view>
<view class="fapiaotaienter ming">
<input placeholder='请输入详细地址' bindinput="enteraddress" placeholder-class='shurufa' value="{{address}}" value="{{address}}" />
</view>
</view>
</view>
<!-- 发票信息 -->
<view class="fapiaoinfo">
<view class="fapiaoword">发票信息</view>
<view class="taitouleixing">
<view class="infoleft">抬头类型</view>
<view class="infoitem" bindtap="selectkind" data-type="0">
<view class="taitouimg">
<image src="{{kindtype==0?'/img/xuan.png':'/img/noxuan.png'}}"></image>
</view>
<view class="qiyedanwei">企业单位</view>
</view>
<view class="infoitem" bindtap="selectkind" data-type="1">
<view class="taitouimg">
<image src="{{kindtype==1?'/img/xuan.png':'/img/noxuan.png'}}"></image>
</view>
<view class="qiyedanwei">个人/非企业单位</view>
</view>
</view>
<view class="fapiaotaitouhead">
<view class="fapiaotai">发票抬头</view>
<view class="fapiaotaienter">
<input placeholder='请输入发票抬头' bindinput="fapiaohead" placeholder-class='shurufa' value="{{invoice}}" />
</view>
</view>
<view class="fapiaotaitouhead">
<view class="fapiaotai">税号</view>
<view class="fapiaotaienter">
<input placeholder='请输入税号' bindinput="shuihao" placeholder-class='shurufa' value="{{number}}" />
</view>
</view>
<!-- <view class="zongjine">
<view class="zongjineleft">总金额</view>
<view class="zongjineright">¥190</view>
</view> -->
</view>
<view class="shezhimoren">
<view class="shezhileft">是否设置为默认用户</view>
<view class="shezhiimg" bindtap="xuanopen">
<image src="/img/close.png" wx:if="{{selshow}}"></image>
<image src="/img/open.png" wx:else></image>
</view>
</view>
<view class="quding" bindtap="editqueding" wx:if="{{editype==1}}">确定</view>
<view class="quding" bindtap="quding" wx:else>确定</view>
\ No newline at end of file
... ...
page {
background: #f5f5fa;
padding: 34rpx 23rpx;
box-sizing: border-box;
}
.tianjiakehu {
color: #141414;
font-size: 40rpx;
font-weight: bold;
}
.kehubox {
width: 702rpx;
border-radius: 28rpx;
padding: 0 23rpx;
box-sizing: border-box;
background: #fff;
margin-top: 30rpx;
}
.kehuitem {
padding: 28rpx 0;
box-sizing: border-box;
border-bottom: 1rpx solid #f5f5f5;
}
.diquitem {
display: flex;
align-items: center;
justify-content: space-between;
}
.diqusel {
color: #9e9e9e;
font-size: 28rpx;
}
.diquright {
display: flex;
align-items: center;
}
.selectdiqu {
font-size: 24rpx;
margin-right: 21rpx;
}
.all {
color: #141414;
font-size: 24rpx;
margin-right: 21rpx;
}
.selcity {
display: flex;
align-items: center;
margin-right: 21rpx;
padding: 0 17rpx;
box-sizing: border-box;
border: 1rpx solid #9e9e9e;
border-radius: 17rpx;
color: #141414;
}
.selimg {
width: 18rpx;
height: 15rpx;
font-size: 0;
}
.quan {
display: flex;
align-items: center;
padding: 0 15rpx;
box-sizing: border-box;
border: 1rpx solid #9e9e9e;
border-radius: 17rpx;
}
.shezhiimg {
width: 70rpx;
height: 68rpx;
font-size: 0;
}
.shezhimoren {
display: flex;
align-items: center;
justify-content: space-between;
padding: 8rpx 23rpx;
box-sizing: border-box;
background: #fff;
margin-top: 38rpx;
border-radius: 28rpx;
}
/* 发票信息 */
.fapiaoinfo {
width: 702rpx;
height: 407rpx;
border-radius: 28rpx;
margin: 53rpx auto 0;
background: #fff;
padding: 36rpx 42rpx;
box-sizing: border-box;
}
.fapiaoinfo {
color: #141414;
font-size: 32rpx;
}
.taitouimg {
width: 14rpx;
height: 14rpx;
font-size: 0;
}
.taitouleixing {
display: flex;
align-items: center;
margin-top: 21rpx;
}
.infoitem {
display: flex;
align-items: center;
margin-left: 39rpx;
}
.infoleft {
color: #9e9e9e;
font-size: 28rpx;
}
.qiyedanwei {
color: #141414;
font-size: 28rpx;
margin-left: 10rpx;
}
.fapiaotai {
width:140rpx;
color: #9e9e9e;
font-size: 28rpx;
margin-top: 21rpx;
}
.zongjine {
display: flex;
align-items: center;
justify-content: space-between;
}
.fapiaoword {
color: #141414;
font-size: 28rpx;
}
.zongjine {
color: #9e9e9e;
font-size: 28rpx;
margin-top: 10rpx;
}
.fapiaotaitouhead {
display: flex;
align-items: center;
}
.fapiaotaienter {
width: 400rpx;
margin-left: 20rpx;
margin-top: 21rpx;
color: #9e9e9e;
font-size: 28rpx;
}
.shurufa{
color: #9e9e9e;
font-size: 28rpx;
}
.kehutian{
display:flex;
align-items: center;
border-bottom:1rpx solid #f5f5f5;
padding: 25rpx 0;
box-sizing: border-box
}
.ming{
margin-top:0
}
.quding{
width:686rpx;
height:88rpx;
background: #2781FB;
color:#fff;
font-size: 28rpx;
text-align: center;
line-height: 88rpx;
margin:40rpx auto 0;
border-radius: 20rpx;
}
.zongjineright{
color:#2781FB;
font-size: 28rpx;
}
.kehuact{
position: relative
}
.kehuact::after{
display:block;
content:'*';
position: absolute;
top:0;
right:-18rpx;
color:#DA0000;
}
\ No newline at end of file
... ...
// pages/fapiaoxinxi/fapiaoxinxi.js
Page({
/**
* 页面的初始数据
*/
data: {
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"usingComponents": {}
}
\ No newline at end of file
... ...
<view class="fapiaoinfo">
<view class="fapiaoword">发票信息</view>
<view class="taitouleixing">
<view class="infoleft">抬头类型</view>
<view class="infoitem">
<view class="taitouimg">
<image src="/img/noxuan.png"></image>
</view>
<view class="qiyedanwei">企业单位</view>
</view>
<view class="infoitem">
<view class="taitouimg">
<image src="/img/noxuan.png"></image>
</view>
<view class="qiyedanwei">个人/非企业单位</view>
</view>
</view>
<view class="fapiaotai">发票抬头</view>
<view class="fapiaotai">税号</view>
<view class="zongjine">
<view class="zongjineleft">总金额</view>
<view class="zongjineright">¥190</view>
</view>
</view>
\ No newline at end of file
... ...
page{
background: #F5F5FA
}
.fapiaoinfo{
width:649rpx;
height:407rpx;
border-radius: 28rpx;
margin:53rpx auto 0;
background: #fff;
padding: 36rpx 42rpx;
box-sizing: border-box
}
.fapiaoinfo{
color:#141414;
font-size: 32rpx;
}
.taitouimg{
width:14rpx;
height:14rpx;
font-size: 0
}
.taitouleixing{
display:flex;
align-items: center;
margin-top:21rpx;
}
.infoitem{
display:flex;
align-items: center;
margin-left:39rpx;
}
.infoleft{
color:#141414;
font-size: 28rpx;
}
.qiyedanwei{
color:#141414;
font-size: 28rpx;
margin-left:10rpx;
}
.fapiaotai{
color:#141414;
font-size: 28rpx;
margin-top:21rpx;
}
.zongjine{
display:flex;
align-items: center;
justify-content: space-between
}
... ...
const app=getApp()
Page({
/**
* 页面的初始数据
*/
data: {
goodnum:1,
buyshow:false,
cart:false,
name:'',
page:1,
goodlist:[],
shangpinming:'',
cartid:'',
count:''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.setData({
name:options.name
})
this.getgoodlist();
},
//获取商品列表
getgoodlist(){
let url = 'index/getGoodsList';
let param = {
keyword:this.data.name,
page: this.data.page
}
app.post(url, param, 'get').then((res) => {
console.log(res);
this.setData({
goodlist: this.data.goodlist.concat(res)
})
}).catch((err) => {
})
},
//获取购物车数量
getcartnum(){
let url ='index/getCarCount'
app.post(url, '', 'get').then((res) => {
console.log(res);
this.setData({
count: res.count
})
}).catch((err) => {
})
},
//输入购物车的数量
entercartnum(e){
this.setData({
goodnum:e.detail.value
})
},
// 增加
add(){
let newgoodnum=this.data.goodnum;
newgoodnum++
this.setData({
goodnum:newgoodnum
})
},
//减少
reduce(){
let newgoodnum = this.data.goodnum;
if (newgoodnum!=1){
newgoodnum = newgoodnum-1
this.setData({
goodnum: newgoodnum
})
}else{
this.setData({
goodnum: 1
})
}
},
//取消
quxiao(){
this.setData({
buyshow:false
})
},
//去购物车
gouwu(){
wx.navigateTo({
url: '/pages/gouwuche/gouwuche',
})
},
//添加购物车
addcart(e){
this.setData({
buyshow:true,
goodnum:1
})
let obj=e.currentTarget.dataset.obj;
console.log(obj)
this.setData({
shangpinming: obj.number,
cartid:obj.id
})
},
//确定加入购物车
quding(){
let that=this;
let url = 'index/addCar';
let param = {
goods_id: this.data.cartid,
number: this.data.goodnum
}
app.post(url, param, 'post').then((res) => {
console.log(res);
wx.showToast({
title: '加入购物车成功',
icon:'none'
})
setTimeout(function(){
wx.navigateTo({
url: '/pages/gouwuche/gouwuche',
})
},1500)
// setTimeout(function(){
// that.setData({
// buyshow:false,
// page:1,
// goodlist:[]
// })
// that.getgoodlist()
// },1000)
}).catch((err) => {
console.log(err)
wx.showToast({
title: err.data.msg,
icon:'none'
})
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.setData({
buyshow:false
})
//获取购物车的数量
this.getcartnum()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
let newpage=this.data.page;
newpage++;
this.setData({
page:newpage
})
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"usingComponents": {}
}
\ No newline at end of file
... ...
<view class="cartkong" wx:if="{{goodlist.length==0}}">
<view class="cartkongimg">
<image src="/img/cartimg.png"></image>
</view>
<view class="konggou">暂无数据</view>
</view>
<view class="cartbox" wx:else>
<view class="cartheadimg">
<image src="/img/bg_head.png"></image>
<view class="carthead">
<view class="cartheaditem">物料编号</view>
<view class="cartheaditem">品名</view>
<view class="cartheaditem">目录价格</view>
<view class="cartheaditem">开发票名</view>
<view class="cartheaditem">库存</view>
<view class="cartheaditem"></view>
</view>
</view>
<view class="cartbox">
<view class="cartboxotem" wx:for="{{goodlist}}" wx:key="">
<view class="boxitemname">{{item.number}}</view>
<view class="boxitemname">{{item.name}}</view>
<view class="boxitemname">{{item.price}}</view>
<view class="boxitemname">{{item.invoice_name}}</view>
<view class="boxitemname">{{item.stock}}</view>
<view class="addimg" bindtap="addcart" data-obj="{{item}}">
<view class="addfuhao">
<image src="/img/addfuhao.png"></image>
</view>
</view>
</view>
</view>
<view class="footbottom">
<view class="footimg" bindtap="gouwu">
<image src="/img/gouwuche.png"></image>
<view class="cartnum">{{count}}</view>
</view>
</view>
<!-- 商品名称购买 -->
<view class="register" wx:if="{{buyshow}}">
<view class="goodwrap">
<view class="goodname">{{shangpinming}}</view>
<view class="selectgood">
<view class="goumaileft">请选择购买商品数量</view>
<view class="goumairight">
<view class="maileft" bindtap="reduce">
-
</view>
<view class="maimiddle">
<input placeholder='{{goodnum}}' value="{{goodnum}}" type="number" bindinput="entercartnum"/>
</view>
<view class="mairight" bindtap="add">+</view>
</view>
</view>
<!-- 取消和确定 -->
<view class="cancelandsure">
<view class="cancel" bindtap="quxiao">取消</view>
<view class="sure" bindtap="quding">确定</view>
</view>
</view>
</view>
</view>
... ...
page{
background:#F5F5FA
}
.cartheadimg{
width:750rpx;
height:85rpx;
font-size: 0;
position: relative
}
.carthead{
width:750rpx;
display:flex;
align-items: center;
justify-content: space-between;
position: absolute;
top:23rpx;
left:23rpx;
}
.cartheaditem{
width:110rpx;
text-align: center;
color:#fff;
font-size: 28rpx;
}
.cartbox{
padding-bottom: 105rpx;
}
.cartboxotem{
display:flex;
align-items: center;
justify-content: space-between;
padding: 20rpx 22rpx;
box-sizing: border-box
}
.cartboxotem:nth-child(2n){
background: #E9E9E9
}
.boxitemname{
width:110rpx;
text-align: center;
color:#000;
font-size: 28rpx;
word-wrap: break-word
/* overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap */
}
.addimg{
width:70rpx;
height:50rpx;
display:flex;
align-items: center
}
.itemaddimg{
width:17rpx;
height:17rpx;
}
.addfuhao{
width:27rpx;
height:27rpx;
font-size: 0;
}
.footbottom{
width:750rpx;
height:100rpx;
background: #fff;
position: fixed;
bottom:0;
left:0;
}
.footimg{
width:132rpx;
height:132rpx;
font-size: 0;
position: absolute;
top:-53rpx;
left:15rpx;
}
.cartnum{
width:40rpx;
height:40rpx;
border-radius: 50%;
background: #FB8423;
text-align: center;
line-height: 40rpx;
position: absolute;
top:0;
right:0;
color:#fff;
font-size: 26rpx;
}
.selectgood{
display:flex;
align-items: center;
justify-content: space-between;
margin-top:63rpx;
}
.goodwrap{
width:705rpx;
/* height:365rpx; */
background: #fff;
border-radius: 20rpx;
position: absolute;
bottom:130rpx;
left:22rpx;
padding: 23rpx 34rpx;
box-sizing: border-box;
}
.goodname{
color:#141414;
font-size: 32rpx;
font-weight: bold;
margin-top:30rpx;
}
.goumairight{
display:flex;
align-items: center;
}
.goumaileft{
color:#141414;
font-size: 24rpx;
}
.maileft{
width:44rpx;
height:35rpx;
border:1rpx solid #f5f5f5;
text-align: center;
line-height: 35rpx;
color:#141414;
font-size: 22rpx;
border-top-left-radius: 16rpx;
border-bottom-left-radius: 16rpx;
}
.maimiddle{
width:185rpx;
height:35rpx;
line-height: 35rpx;
border:1rpx solid #f5f5f5;
border-left:none;
text-align: center;
display:flex;
align-items: center;
color:#141414;
font-size: 22rpx;
}
.maimiddle input{
/* height:35rpx!important;
line-height: 35rpx;
min-height:35rpx!important;
border:none;
outline:none;
display:flex;
align-items: center;
padding-top: 2rpx;
box-sizing: border-box */
}
.mairight{
width:44rpx;
height:35rpx;
border:1rpx solid #f5f5f5;
text-align: center;
line-height: 35rpx;
border-left:none;
color:#FF5A00;
font-size: 22rpx;
border-top-right-radius: 16rpx;
border-bottom-right-radius: 16rpx;
}
.cancelandsure{
display:flex;
align-items: center;
justify-content: space-between;
margin-top:54rpx;
}
.cancel{
width:243rpx;
height:83rpx;
background: #E9E9E9;
color:#141414;
font-size: 28rpx;
text-align: center;
line-height: 83rpx;
border-radius: 20rpx;
}
.sure{
width:369rpx;
height:83rpx;
background: #2781FB;
color:#fff;
font-size: 28rpx;
text-align: center;
line-height: 83rpx;
border-radius: 20rpx;
}
.cartkongimg{
width:399rpx;
height:491rpx;
font-size: 0;
margin:179rpx auto 0;
}
.konggou{
color:#141414;
font-size: 32rpx;
text-align: center;
margin-top:57rpx;
}
\ No newline at end of file
... ...
const app=getApp();
Page({
/**
* 页面的初始数据
*/
data: {
cartlist:[],
allselect:false,
cartidarr:[],
cartnumarr:[],
numcart:'',
ti:1
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
//获取购物车列表
getcartlsit(){
let url ='index/getCarList'
app.post(url, '', 'get').then((res) => {
console.log(res);
for(var obj of res){
obj.select=false
}
this.setData({
cartlist:res
})
console.log(this.data.cartlist)
}).catch((err) => {
})
},
nosel(){
},
//输入购物车的数量
entercartnum(e){
let id=e.currentTarget.dataset.id;
console.log(id)
let newcartlist = this.data.cartlist;
let newcartnumarr = this.data.cartnumarr;
for (var obj of newcartlist){
if(obj.goods_id==id){
obj.count=e.detail.value;
this.setData({
numcart:obj.count
})
}
}
for (var obj of newcartnumarr) {
if (obj.id == id) {
obj.num = this.data.numcart;
}
}
this.setData({
cartlist: newcartlist,
cartnumarr: newcartnumarr
})
},
//增加购物车的数量
addcart(e){
let id=e.currentTarget.dataset.id;
let newcartlist=this.data.cartlist;
let newcartnumarr=this.data.cartnumarr;
for(var obj of newcartlist){
if(obj.goods_id==id){
obj.count = Number(obj.count)+1;
this.setData({
numcart:obj.count
})
}
}
for(var obj of newcartnumarr){
if(obj.id==id){
obj.num=this.data.numcart;
}
}
this.setData({
cartlist: newcartlist,
cartnumarr: newcartnumarr
})
},
//减少购物车数量
reducecart(e){
let id = e.currentTarget.dataset.id;
let newcartlist = this.data.cartlist;
let newcartnumarr=this.data.cartnumarr;
for (var obj of newcartlist) {
if (obj.goods_id == id) {
if (obj.count==1){
obj.count=1;
this.setData({
numcart: obj.count
})
}else{
obj.count = Number(obj.count) -1;
this.setData({
numcart: obj.count
})
}
}
}
for (var obj of newcartnumarr) {
if (obj.id == id) {
obj.num = this.data.numcart;
}
}
this.setData({
cartlist: newcartlist,
cartnumarr:newcartnumarr,
})
console.log(this.data.cartnumarr)
},
//删除购物车
delcart(e){
console.log(e)
let id=e.currentTarget.dataset.id;
let url = 'index/delCar';
let param={
goods_id:id
}
app.post(url, param, 'get').then((res) => {
console.log(res);
wx.showToast({
title: '删除成功',
icon:"none"
})
this.getcartlsit()
}).catch((err) => {
})
},
//选择购物车
chosecart(e){
let id=e.currentTarget.dataset.id;
let newcartlist = this.data.cartlist;
let newcartidarr=this.data.cartidarr;
let newcartnumarr=this.data.cartnumarr;
let opt={}
for(var obj of newcartlist){
if(obj.goods_id==id){
obj.select=!obj.select;
if(obj.select==true){
opt.id = obj.goods_id;
opt.num=obj.count;
newcartidarr.push(obj.goods_id);
newcartnumarr.push(opt)
}else{
let newcartidarr=this.data.cartidarr;
for(var i=0;i<newcartidarr.length;i++){
if (newcartidarr[i]==id){
newcartidarr.splice(i,1);
}
}
for (var j = 0; j < newcartnumarr.length; j++) {
if (newcartnumarr[j].num == obj.count) {
newcartnumarr.splice(j, 1);
}
}
}
}
}
if (newcartidarr.length==this.data.cartlist.length){
this.setData({
allselect:true
})
}else{
this.setData({
allselect: false
})
}
this.setData({
cartidarr:newcartidarr,
cartlist:newcartlist,
cartnumarr:newcartnumarr
})
console.log(this.data.cartnumarr)
},
//全选购物车
quanxuan(){
this.setData({
allselect: !this.data.allselect
})
if(this.data.allselect==true){
let newcartlist = this.data.cartlist;
let newcartidarr = [];
let newcartnumarr=[];
for(var obj of newcartlist){
let opt = {};
console.log(obj)
obj.select=true;
newcartidarr.push(obj.goods_id);
opt.id = obj.goods_id;
opt.num = obj.count;
console.log(opt)
newcartnumarr.push(opt)
}
this.setData({
cartlist:newcartlist,
cartidarr:newcartidarr,
cartnumarr:newcartnumarr
})
}else{
let newcartlist = this.data.cartlist;
for(var obj of newcartlist){
obj.select=false
}
this.setData({
cartidarr: [],
cartnumarr:[],
cartlist:newcartlist
})
}
},
tijaiodingdan() {
let that=this;
if (that.data.cartidarr.length==0){
wx.showToast({
title: '请选择购买商品',
icon:'none'
})
return false
}else{
that.setData({
ti:''
})
console.log(that.data.ti)
let newcartnumarr = that.data.cartnumarr;
console.log(newcartnumarr)
let numarr = [];
for (var obj of newcartnumarr) {
numarr.push(obj.num)
}
numarr = numarr.join(",");
let newcartidarr = that.data.cartidarr;
newcartidarr = newcartidarr.join(",");
console.log(numarr);
let url = 'index/addOrder';
let param = {
goods_id: newcartidarr,
amount: numarr
}
app.post(url, param, 'post').then((res) => {
console.log(res);
wx.setStorageSync('orderarr', res.data);
wx.setStorageSync('total_price', res.total_price)
wx.showToast({
title: '提交订单成功',
icon: 'none'
})
setTimeout(function () {
wx.navigateTo({
url: '/pages/orderdetail/orderdetail',
})
}, 1000)
}).catch((err) => {
})
}
},
//删除购物车
shanchucart(){
let that=this;
let newcartidarr=this.data.cartidarr;
if(newcartidarr.length==0){
wx.showToast({
title: '请选择要删除的商品',
icon:'none'
})
return false
}
let url = 'index/delCar';
let param = {
goods_id: newcartidarr.join(","),
}
app.post(url, param, 'get').then((res) => {
console.log(res);
wx.showToast({
title: '删除购物车成功',
icon: 'none'
})
that.getcartlsit();
}).catch((err) => {
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.setData({
cartlist: [],
allselect: false,
cartidarr: [],
cartnumarr: [],
})
this.getcartlsit()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"usingComponents": {}
}
\ No newline at end of file
... ...
<view class="gouwuche">购物车</view>
<view class="cartkong" wx:if="{{cartlist.length==0}}">
<view class="cartkongimg">
<image src="/img/cartimg.png"></image>
</view>
<view class="konggou">购物车空空如也</view>
</view>
<view class="gouwubox" wx:else>
<view class="gouwuitem" wx:for="{{cartlist}}" wx:key="" bindtap="chosecart" data-id="{{item.goods_id}}">
<view class="gouitemleft" wx:if="{{item.select==true}}" >
<image src="/img/xuanzhong.png"></image>
</view>
<view class="gouitemleft" wx:else>
<image src="/img/noselect.png"></image>
</view>
<view class="goumairight">
<view class="goumaitop">
<view class="goumiddletop">物料编号 : {{item.number}}</view>
<view class="shanimg" catchtap="delcart" data-id="{{item.goods_id}}">
<image src="/img/delshan.png"></image>
</view>
</view>
<view class="goumiddletop">商品名称 : {{item.name}}</view>
<view class="goumiddletop">开发票品名 : {{item.invoice_name}}</view>
<view class="kaimoney">
<view class="singleprice">¥{{item.price}}</view>
<view class="goumaishu">
<view class="goumaishuleft" catchtap="reducecart" data-id="{{item.goods_id}}">-</view>
<view class="goumaishumiddle" catchtap='nosel'>
<input placeholder='{{item.count}}' value="{{item.count}}" bindinput="entercartnum" data-id="{{item.goods_id}}"/>
</view>
<view class="goumaishuright" catchtap="addcart" data-id="{{item.goods_id}}">+</view>
</view>
</view>
</view>
</view>
</view>
<view class="orderfoot">
<view class="orderfoottop">
<view class="footleft" bindtap="quanxuan">
<view class="footleftimg" wx:if="{{allselect==true}}" >
<image src="/img/xuanzhong.png"></image>
</view>
<view class="footleftimg" wx:else >
<image src="/img/noselect.png"></image>
</view>
<view class="quanxuan">全选</view>
</view>
<view class="footright" catchtap="shanchucart">删除</view>
</view>
<view class="orderbottom" bindtap="tijaiodingdan" wx:if="{{ti==1}}">
提交订单
</view>
<view class="orderbottom" wx:else>
提交订单
</view>
</view>
\ No newline at end of file
... ...
page {
background: #f5f5fa;
}
.gouwuche {
color: #141414;
font-size: 40rpx;
font-weight: bold;
padding: 34rpx 23rpx 10rpx 23rpx;
box-sizing: border-box;
}
.gouwuitem {
padding: 34rpx 46rpx 34rpx 18rpx;
box-sizing: border-box;
background: #fff;
width: 702rpx;
margin: 28rpx auto 0;
border-radius: 28rpx;
display: flex;
align-items: center;
}
.goumaitop {
display: flex;
align-items: center;
justify-content: space-between;
}
.kaimoney {
display: flex;
align-items: center;
justify-content: space-between;
margin-top:10rpx;
}
.gouitemleft {
width: 22rpx;
height: 22rpx;
font-size: 0;
}
.goumairight {
flex: 1;
margin-left: 40rpx;
}
.shanimg {
width: 26rpx;
height: 31rpx;
font-size: 0;
}
.gouitemtop {
display: flex;
align-items: center;
justify-content: space-between;
}
.goumaishu {
display: flex;
align-items: center;
}
.goumaishuleft {
width: 44rpx;
height: 31rpx;
border: 1rpx solid #f5f5f5;
border-top-left-radius: 16rpx;
border-bottom-left-radius: 16rpx;
text-align: center;
line-height: 31rpx;
border-right: none;
color: #141414;
font-size: 24rpx;
}
.goumaishumiddle {
width: 161rpx;
height: 31rpx;
line-height: 31rpx;
border: 1rpx solid #f5f5f5;
text-align: center;
color: #141414;
font-size: 24rpx;
border-right: none;
display:flex;
align-items: center
}
.goumaishumiddle input{
/* height:31rpx!important;
min-height:31rpx!important;
line-height: 31rpx;
border:none;
outline:none;
display:flex;
align-items: center */
}
.goumaishuright {
width: 44rpx;
height: 31rpx;
border: 1rpx solid #f5f5f5;
text-align: center;
line-height: 31rpx;
border-right: none;
color: #141414;
font-size: 24rpx;
border-top-right-radius: 16rpx;
border-bottom-right-radius: 16rpx;
}
.goumiddletop {
color: #141414;
font-size: 26rpx;
margin-top: 10rpx;
}
.singleprice {
color: #e60000;
font-size: 26rpx;
}
.gouwubox{
padding-bottom: 200rpx;
}
.orderfoot {
position: fixed;
bottom: 0;
left: 0;
}
.orderfoottop {
width: 750rpx;
display: flex;
align-items: center;
justify-content: space-between;
padding: 31rpx 42rpx;
box-sizing: border-box;
background: #e9e9e9;
}
.footleft {
display: flex;
align-items: center;
}
.footleftimg{
width:22rpx;
height:22rpx;
font-size: 0
}
.quanxuan{
color:#141414;
font-size: 26rpx;
margin-left:20rpx;
}
.footright{
color:#DA0000;
font-size: 24rpx;
}
.orderbottom{
width:750rpx;
height:88rpx;
background: #2781FB;
color:#fff;
font-size: 24rpx;
text-align: center;
line-height: 88rpx;
}
.cartkongimg{
width:399rpx;
height:491rpx;
font-size: 0;
margin:179rpx auto 0;
}
.konggou{
color:#141414;
font-size: 32rpx;
text-align: center;
margin-top:57rpx;
}
\ No newline at end of file
... ...
//index.js
//获取应用实例
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'
})
},
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: function(e) {
console.log(e)
app.globalData.userInfo = e.detail.userInfo
this.setData({
userInfo: e.detail.userInfo,
hasUserInfo: true
})
}
})
... ...
{
"usingComponents": {}
}
\ No newline at end of file
... ...
<!--index.wxml-->
<view class="container">
<view class="userinfo">
<button wx:if="{{!hasUserInfo && canIUse}}" open-type="getUserInfo" bindgetuserinfo="getUserInfo"> 获取头像昵称 </button>
<block wx:else>
<image bindtap="bindViewTap" class="userinfo-avatar" src="{{userInfo.avatarUrl}}" mode="cover"></image>
<text class="userinfo-nickname">{{userInfo.nickName}}</text>
</block>
</view>
<view class="usermotto">
<text class="user-motto">{{motto}}</text>
</view>
</view>
... ...
/**index.wxss**/
.userinfo {
display: flex;
flex-direction: column;
align-items: center;
}
.userinfo-avatar {
width: 128rpx;
height: 128rpx;
margin: 20rpx;
border-radius: 50%;
}
.userinfo-nickname {
color: #aaa;
}
.usermotto {
margin-top: 200px;
}
\ No newline at end of file
... ...
// pages/login/login.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
loginshow: false,
errmima: false,
zhanghao: "",
mima: ''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
},
//输入账号
enterzhanghao(e) {
this.setData({
zhanghao: e.detail.value
})
},
//输入密码
entermima(e) {
this.setData({
mima: e.detail.value
})
},
//登录页面
login() {
// var reg = new RegExp("^[a-z0-9]+([._\\-]*[a-z0-9])*@([a-z0-9]+[-a-z0-9]*[a-z0-9]+.){1,63}[a-z0-9]+$");
// if (this.data.zhanghao != '') {
// if (!reg.test(this.data.zhanghao)) {
// wx.showToast({
// title: '请输入正确的邮箱格式',
// icon: 'none'
// })
// return false
// }
// }
let url = 'user/login'
let param = {
mobile: this.data.zhanghao,
password: this.data.mima
}
app.post(url, param, 'post').then((res) => {
console.log(res);
wx.setStorageSync("token", res.token);
wx.setStorageSync("username", res.username)
setTimeout(function() {
wx.switchTab({
url: '/pages/sousuo/sousuo',
})
}, 1000)
}).catch((err) => {
console.log(err)
wx.showToast({
title: err.data.msg,
icon: 'none'
})
})
},
hideloginwrap() {
this.setData({
loginshow: false
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
}
})
\ No newline at end of file
... ...
{
"usingComponents": {},
"navigationBarTitleText": "中源生物"
}
\ No newline at end of file
... ...
<view class="page">
<image src='/img/bejing.png'></image>
<view class="baibeijing">
<view class="shengwuimg">
<image src="/img/logo.png"></image>
</view>
<view class="shuruhao">
<input placeholder='请输入邮箱' placeholder-class='enterzhang' type="text" value="{{zhanghao}}" bindinput="enterzhanghao"/>
</view>
<view class="shuruhao shumima">
<input placeholder='请输入密码' placeholder-class='enterzhang' type="password" value="{{mima}}" bindinput="entermima"/>
</view>
<view class="dengluniu" bindtap="login">登录</view>
</view>
</view>
<view class="register" wx:if="{{loginshow}}">
<view class="loginwrap" bindtap="hideloginwrap">
<image src="/img/dengluchenggong.png"></image>
<view class="loginsuccess">登录成功</view>
</view>
</view>
<!-- 账号或密码错误 -->
<view class="zhanghaoregister" wx:if="{{errmima}}">
<view class="zhanghaowrap">*账号或密码错误</view>
</view>
\ No newline at end of file
... ...
/* pages/login/login.wxss */
page {
width: 100%;
height: 100%;
overflow-y: hidden;
}
.page {
width: 100%;
height: 100%;
}
image {
width: 100%;
height: 100%;
}
.shengwuimg {
width: 421rpx;
height: 134rpx;
font-size: 0;
margin: 116rpx auto 0;
}
.baibeijing {
width: 634rpx;
height: 847rpx;
background: rgba(253, 253, 254, 1);
box-shadow: 0rpx 7rpx 8rpx 0rpx rgba(25, 103, 175, 0.08);
border-radius: 28rpx;
position: absolute;
top: 167rpx;
left: 61rpx;
}
.shuruhao {
width: 479rpx;
height: 78rpx;
background: rgba(241, 241, 241, 1);
border: 1px solid rgba(228, 228, 228, 1);
border-radius: 39rpx;
margin: 111rpx auto 0;
padding: 0 37rpx;
box-sizing: border-box;
color: #bbb;
font-size: 28rpx;
}
.shuruhao input {
width: 100%;
height: 70rpx;
background: rgba(241, 241, 241, 1);
border: none;
outline: none;
border-radius: 39rpx;
color: #bbb;
font-size: 28rpx;
}
.enterzhang {
color: #bbb;
font-size: 28rpx;
}
.shumima {
margin-top: 28rpx;
}
.dengluniu {
width: 290rpx;
height: 85rpx;
background: #30a8ff;
border-radius: 28rpx;
text-align: center;
line-height: 85rpx;
margin: 123rpx auto 0;
color: #fff;
}
.loginwrap {
width: 354rpx;
height: 374rpx;
font-size: 0;
margin: 358rpx auto 0;
position: relative;
}
.loginsuccess {
color: #2c2c2c;
font-size: 28rpx;
position: absolute;
top: 197rpx;
left: 126rpx;
}
.zhanghaoregister {
width: 100%;
height: 100%;
background-color: rgba(0, 0, 0, 0.5);
position: fixed;
top: 0;
left: 0;
right: 0;
z-index: 5;
}
.zhanghaowrap{
width:344rpx;
height:74rpx;
border-radius: 28rpx;
background: #fff;
display:flex;
align-items: center;
justify-content: center;
position: absolute;
top:60rpx;
left:203rpx;
}
\ No newline at end of file
... ...
//logs.js
const util = require('../../utils/util.js')
Page({
data: {
logs: []
},
onLoad: function () {
this.setData({
logs: (wx.getStorageSync('logs') || []).map(log => {
return util.formatTime(new Date(log))
})
})
}
})
... ...
{
"navigationBarTitleText": "查看启动日志",
"usingComponents": {}
}
\ No newline at end of file
... ...
<!--logs.wxml-->
<view class="container log-list">
<block wx:for="{{logs}}" wx:for-item="log">
<text class="log-item">{{index + 1}}. {{log}}</text>
</block>
</view>
... ...
.log-list {
display: flex;
flex-direction: column;
padding: 40rpx;
}
.log-item {
margin: 10rpx;
}
... ...
// pages/mine/mine.js
Page({
/**
* 页面的初始数据
*/
data: {
yonghuname:''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
//我的客户
mykehu(){
let token = wx.getStorageSync("token");
if (token == '') {
wx.showToast({
title: '请先登录',
icon: 'none'
})
setTimeout(function () {
wx.navigateTo({
url: '/pages/login/login',
})
}, 1500)
}else{
wx.navigateTo({
url: '/pages/mykehu/mykehu',
})
}
},
//我的订单
myorder(){
let token = wx.getStorageSync("token");
if (token == '') {
wx.showToast({
title: '请先登录',
icon: 'none'
})
setTimeout(function () {
wx.navigateTo({
url: '/pages/login/login',
})
}, 1500)
}else{
wx.navigateTo({
url: '/pages/myorder/myorder',
})
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
let username=wx.getStorageSync("username");
if(username==''){
this.setData({
yonghuname:'暂无'
})
}else{
this.setData({
yonghuname:username
})
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"usingComponents": {}
}
\ No newline at end of file
... ...
<view class="myname">{{yonghuname}}</view>
<view class="minebox">
<view class="mineitem" bindtap="mykehu">
<view class="mineitemleft">我的客户</view>
<view class="mineitemright">
<image src="/img/yourow.png"></image>
</view>
</view>
<view class="mineitem" bindtap="myorder">
<view class="mineitemleft">我的订单</view>
<view class="mineitemright">
<image src="/img/yourow.png"></image>
</view>
</view>
</view>
... ...
page{
background: #F5F5FA;
}
.minebox{
width:702rpx;
background: #fff;
margin:179rpx auto 0;
border-radius: 28rpx;
}
.myname{
color:#141414;
font-size: 34rpx;
text-align: center;
margin-top:164rpx;
font-weight: bold;
}
.mineitem{
display:flex;
align-items: center;
justify-content: space-between;
padding: 24rpx 36rpx;
box-sizing: border-box
}
.mineitemright{
width:13rpx;
height:28rpx;
font-size: 0
}
\ No newline at end of file
... ...
// pages/mykehu/mykehu.js
const app=getApp()
Page({
/**
* 页面的初始数据
*/
data: {
kehulist:[],
page:1,
morenkehu:'',
showmoren:true,
letter: ["A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z","#"],
cityListId:'',
scrollHeight:"",
len:''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
//获取默认客户
getmorenkehu(){
console.log(7654321)
let that = this;
let url = 'user/getCustomerList';
let param = {
page: 1,
is_default: 1
}
app.post(url, param, 'get').then((res) => {
console.log(res);
this.setData({
morenkehu:res[0]
})
console.log(res.length)
if(res.length==0){
that.setData({
showmoren:false
})
}else{
that.setData({
showmoren:true
})
}
}).catch((err) => {
})
},
//获取客户列表
getkehulist(){
let that = this;
let url = 'user/getCustomerList';
let param={
page:this.data.page,
is_default:0
}
app.post(url, param, 'get').then((res) => {
console.log(res);
this.setData({
kehulist:this.data.kehulist.concat(res)
})
let len = this.data.kehulist.length;
console.log(len)
len = len * 120+100;
this.setData({
len: len
})
}).catch((err) => {
})
},
//编辑客户
editkehu(e){
let id=e.currentTarget.dataset.id;
wx.navigateTo({
url: '/pages/addkehu/addkehu?editype='+1+'&id='+id,
})
},
//删除客户
delkehu(e){
console.log(e)
let that = this;
let id=e.currentTarget.dataset.id
let url = 'user/delCustomer';
let param = {
customer_id: id,
}
app.post(url, param, 'get').then((res) => {
console.log(res);
wx.showToast({
title: '删除客户成功',
icon:"none"
})
setTimeout(function(){
that.setData({
page: 1,
kehulist: []
})
that.getkehulist();
that.getmorenkehu();
},1500)
}).catch((err) => {
})
},
//选择默认地址
select(e){
let item = e.currentTarget.dataset.item;
console.log(item)
let pages = getCurrentPages();
// let currPage = pages[pages.length - 1]; //当前页面
let prevPage = pages[pages.length - 2]; //上一个页面
//直接调用上一个页面的setData()方法,把数据存到上一个页面中去
prevPage.setData({
morenaddress:item,
prepage:1
});
wx.navigateBack({
checked:true
})
},
//添加新客户
addkehu(){
wx.navigateTo({
url: '/pages/addkehu/addkehu',
})
},
letterTap(e) {
console.log(e)
const Item = e.currentTarget.dataset.item;
console.log('000888',Item)
// this.setData({
// cityListId: Item
// });
// let scrollHeight = wx.getSystemInfoSync().windowHeight;
// this.setData({
// scrollHeight: scrollHeight
// })
// var query = wx.createSelectorQuery();
// var that = this;
// query.select('.city_left').boundingClientRect(function (rect) {
// console.log('66666',rect)
// }).exec();
//滚动到某一位置
// var me = this;
// var query = wx.createSelectorQuery().in(me);
// query.selectViewport().scrollOffset()
// query.select("#comment").boundingClientRect();
// query.exec(function (res) {
// console.log(res);
// var miss = res[0].scrollTop + res[1].top - 10;
// wx.pageScrollTo({
// scrollTop: miss,
// duration: 300
// });
// });
if (Item == '#') {
this.setData({
scrollHeight: this.data.len
});
} else {
this.setData({
cityListId: Item
});
}
console.log('909090', this.data.scrollHeight)
console.log('77777', Item)
console.log("..............." + this.data.cityListId);
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
//获取默认客户
this.getmorenkehu();
this.setData({
kehulist:[],
page:1
})
this.getkehulist();
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
let newpage=this.data.page;
newpage++;
this.setData({
page:newpage
})
this.getkehulist()
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"usingComponents": {}
}
\ No newline at end of file
... ...
<view class='mykehuhead'>
<view class="mykehuleft">我的客户</view>
<view class="addkehu" bindtap="addkehu">添加新客户</view>
</view>
<view class="kehubox morenke" wx:if="{{showmoren}}">
<view class="kehuitem" bindtap="select" data-item="{{morenkehu}}">
<view class="itemleftimg">
<image src="/img/address.png"></image>
</view>
<view class="itemmiddle">
<view class="itemmiddletop">{{morenkehu.customer_name}} {{morenkehu.contact_name}}</view>
<view class="itemmiddlebottom">{{morenkehu.receive_name}} {{morenkehu.mobile}} </view>
<view class="itemmiddlebottom">{{morenkehu.address}}</view>
</view>
<view class="delimg">
<view class="itemright edigtupian" catchtap='editkehu' data-id="{{morenkehu.id}}">
<image src="/img/editaddress.png"></image>
</view>
<view class="itemright" catchtap='delkehu' data-id="{{morenkehu.id}}">
<image src="/img/delshan.png"></image>
</view>
</view>
</view>
</view>
<!-- <view class="kehubox">
<view class="kehuitem" wx:for="{{kehulist}}" wx:key="" bindtap="select" data-item="{{item}}">
<view class="itemleftimg">
<image src="/img/address.png"></image>
</view>
<view class="itemmiddle">
<view class="itemmiddletop">{{item.customer_name}} {{item.mobile}}</view>
<view class="itemmiddlebottom">{{item.region}} {{item.address}}</view>
</view>
<view class="delimg">
<view class="itemright edigtupian" catchtap='editkehu' data-id="{{item.id}}">
<image src="/img/editaddress.png"></image>
</view>
<view class="itemright" catchtap='delkehu' data-id="{{item.id}}">
<image src="/img/delshan.png"></image>
</view>
</view>
</view>
</view> -->
<view class='city_box'>
<view class='city_left'>
<scroll-view style='width:100%;height:100%;' scroll-with-animation scroll-into-view='{{cityListId}}' class="citybox" scroll-y='true' scroll-top="{{scrollHeight}}">
<!-- <view class="hot">
<view class="hotimg">
<image src="{{url}}bicon_08@2x.png"></image>
</view>
<view class="hotzi">
<image src="{{url}}bicon_07@2x.png"></image>
</view>
</view> -->
<!-- <view class='new_city'>
<view class='new_city_box'>
<view class='new_city_text' wx:for='{{newcity}}' wx:key='this' data-types='new' catchtap='cityTap' data-val='{{item}}'>
<view class="hotgood" bindtap="jumpbrand" data-id="{{item.id}}">
<view class="imgleft">
<image src="{{item.logo}}" mode='aspectFit'></image>
</view>
<view class="contentright">
<view class="contenttop">{{item.name}}</view>
<view class="contenbottom">
<text class="textname">{{item.sort_name}}</text>
<text class="textname">{{item.country}}</text>
<text class="textname">{{item.city}}</text>
<text class="textname">{{item.odor_name}}</text>
</view>
</view>
</view>
</view>
</view>
</view> -->
<view class='city_list_box'>
<block wx:for='{{kehulist}}' wx:key='this' wx:for-item='letterItem' wx:for-index='letterIndex'>
<view class='city_first_letter' id='{{letterItem.acronym}}'>{{letterItem.acronym}}</view>
<!-- {{item.cityName}} -->
<view class='city_name' wx:for='{{letterItem.list}}' id='{{letterItem.acronym}}' wx:key='this' data-types='list' bindtap="jumpbrand" data-id="{{item.id}}" data-index='{{index}}' data-val='{{item}}'>
<!-- <view class="imgleft">
<image src="{{item.logo}}" mode="aspectFit"></image>
</view> -->
<view class="contentright">
<view class="contenttop">{{item.acronym}}</view>
<view class="kehuitem" bindtap="select" data-item="{{item}}">
<view class="itemleftimg">
<image src="/img/address.png"></image>
</view>
<view class="itemmiddle">
<view class="itemmiddletop">{{item.customer_name}} {{item.contact_name}}</view>
<view class="itemmiddlebottom">{{item.receive_name}} {{item.mobile}}</view>
<view class="itemmiddlebottom">{{item.address}}</view>
</view>
<view class="delimg">
<view class="itemright edigtupian" catchtap='editkehu' data-id="{{item.id}}">
<image src="/img/editaddress.png"></image>
</view>
<view class="itemright" catchtap='delkehu' data-id="{{item.id}}">
<image src="/img/delshan.png"></image>
</view>
</view>
</view>
</view>
</view>
</block>
</view>
</scroll-view>
</view>
<view class='city_right'>
<text class='letter_item' wx:for='{{letter}}' wx:key='this' catchtap='letterTap' data-item='{{item}}'>{{item}}</text>
</view>
</view>
\ No newline at end of file
... ...
page{
background: #F5F5FA;
height:100%;
}
.kehubox{
width:702rpx;
margin:20rpx auto 0;
background: #fff;
border-radius: 28rpx;
padding: 0rpx 29rpx;
box-sizing: border-box;
margin-bottom:50rpx;
}
.mykehuhead{
display:flex;
align-items: center;
justify-content: space-between;
padding: 34rpx 23rpx 20rpx 23rpx;
box-sizing: border-box;
}
.mykehuleft{
color:#141414;
font-size: 40rpx;
font-weight: bold;
}
.addkehu{
color:#2781FB;
font-size: 28rpx;
}
.kehuitem{
display:flex;
align-items: center;
justify-content: space-between;
padding: 36rpx 0;
box-sizing: border-box;
border-bottom:1rpx solid #f5f5f5;
}
.itemleftimg{
width:35rpx;
height:34rpx;
font-size:0;
}
.itemright{
width:28rpx;
height:27rpx;
font-size: 0
}
.itemmiddle{
width:439rpx;
border-right:1rpx solid #f5f5f5;
padding-right: 68rpx;
box-sizing: border-box
}
.itemmiddletop{
color:#141414;
font-size: 28rpx;
}
.itemmiddlebottom{
width:410rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color:#141414;
font-size: 28rpx;
margin-top:20rpx;
}
.morenke{
margin-bottom:30rpx
}
.delimg{
display:flex;
align-items: center
}
.edigtupian{
margin-right:40rpx;
}
.city_box{
height:100%;
background: #fff;
display: flex;
}
.city_left{
flex: 1;
}
.city_right{
width: 60rpx;
display: flex;
flex-direction: column;
justify-content: space-around;
}
.letter_item{
flex: 1;
display: block;
font-size: 24rpx;
color: #33B9FF;
text-align: center;
}
.city_locate,.national{
height: 80rpx;
line-height: 80rpx;
border-bottom: 1px solid #efefef;
font-size: 28rpx;
color: #333;
padding-left: 25rpx;
}
.city_locate_title{
color: #999;
margin-right: 20rpx;
}
.new_city{
background: #efefef;
font-size: 28rpx;
}
.new_city_title{
line-height: 50rpx;
color: #999;
padding-left: 25rpx;
margin-bottom: 20rpx;
}
.new_city_box{
display: flex;
flex-wrap: wrap;
}
.new_city_text{
width: 200rpx;
text-align: center;
line-height: 70rpx;
background: #fff;
border-radius: 35rpx;
margin:0 0 22rpx 22rpx;
}
.city_first_letter{
line-height: 40rpx;
height: 40rpx;
padding-left: 25rpx;
font-size: 28rpx;
background: #eee;
color: #999;
}
.city_name{
display: block;
/* line-height: 80rpx;
height: 80rpx; */
border-bottom: 1px solid #efefef;
font-size: 28rpx;
color: #333;
padding-left: 25rpx;
}
\ No newline at end of file
... ...
// pages/myorder/myorder.js
const app=getApp()
Page({
/**
* 页面的初始数据
*/
data: {
page:1,
orderlist:[]
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.germyorder()
},
//获取我的订单
germyorder(){
let that=this;
let url = 'user/getMyOrderList';
let param={
page:this.data.page
}
app.post(url, param, 'get').then((res) => {
console.log(res);
for(var obj of res){
obj.total_price = obj.total_price.toFixed("2")
}
that.setData({
orderlist:that.data.orderlist.concat(res)
})
}).catch((err) => {
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
let newpage=this.data.page;
newpage++;
this.setData({
page:newpage
})
this.germyorder()
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"usingComponents": {}
}
\ No newline at end of file
... ...
<view class="myordername">
我的订单
</view>
<view class="cartkong" wx:if="{{orderlist.length==0}}">
<view class="cartkongimg">
<image src="/img/cartimg.png"></image>
</view>
<view class="konggou">暂无数据</view>
</view>
<view class="orderbox" wx:else>
<view class="orderitem" wx:for="{{orderlist}}" wx:key="">
<view class="orderitemhead">
<view class="orderitemleft">
<view class="lianxiname">
<view class="kehuname">{{item.customer_name}}</view>
<view class="kehunameo">{{item.mobile}}</view>
<view class="orderitemright">{{item.createtime}}</view>
</view>
<view class="lanxianren">联系人:
<text wx:if="{{item.contact_name!=''}}">{{item.contact_name}}</text>
<text wx:else>暂无</text> </view>
<view class="shouhuoren">收货人:
<text wx:if="{{item.receive_name!=''}}">{{item.receive_name}}</text>
<text wx:else>暂无</text>
</view>
<view class="lanxianren">订单流水号:{{item.order_sn}}</view>
</view>
</view>
<view class="orderbox">
<view class="orderboxitem" wx:for="{{item.order}}" wx:key="">
<view class="ordercontent">
<view class="contentname">{{item.number}}</view>
<view class="contentnum">{{item.name}}</view>
</view>
<view class="orderitemnum">x{{item.amount}}</view>
<view class="beizhu">备注:
<text wx:if="{{item.mark!=''}}">{{item.mark}}</text>
<text wx:else>暂无备注</text>
</view>
</view>
</view>
<view class="ordermoney">
<view class="ordermoneyleft">总金额</view>
<view class="ordermoneyright">¥{{item.total_price}}</view>
</view>
</view>
</view>
\ No newline at end of file
... ...
page {
padding: 0 23rpx;
box-sizing: border-box;
background: #f5f5fa;
}
.myordername {
color: #141414;
font-size: 38rpx;
padding: 34rpx 0 0rpx;
box-sizing: border-box;
font-weight: bold;
}
.orderbox{
padding-bottom: 20rpx;
}
.orderitem {
width: 702rpx;
background: #fff;
padding: 27rpx 40rpx;
box-sizing: border-box;
border-radius: 28rpx;
margin-top:27rpx;
}
.orderitemhead {
display: flex;
align-items: center;
justify-content: space-between;
}
.kehuname {
width:258rpx;
overflow: hidden;
text-overflow: ellipsis;
white-space: nowrap;
color: #141414;
font-size: 32rpx;
}
.kehunameo {
color: #9e9e9e;
font-size: 28rpx;
margin-left: 17rpx;
}
.orderitemright {
color: #9e9e9e;
font-size: 28rpx;
margin-left:20rpx;
}
.ordercontent {
display: flex;
align-items: center;
margin-top: 10rpx;
}
.contentname {
color: #9e9e9e;
font-size: 24rpx;
}
.contentnum {
color: #9e9e9e;
font-size: 24rpx;
margin-left: 17rpx;
}
.orderitemnum {
color: #9e9e9e;
font-size: 24rpx;
margin-top: 5rpx;
}
.ordermoney {
display: flex;
align-items: center;
justify-content: flex-end;
}
.ordermoneyleft {
color: #141414;
font-size: 32rpx;
margin-right: 31rpx;
}
.ordermoneyright{
color:#2781FB;
font-size: 32rpx;
margin-right:15rpx;
}
.lianxiname{
display:flex;
align-items: center
}
.lanxianren{
color:#9E9E9E;
font-size: 28rpx;
margin-top:10rpx;
}
.shouhuoren{
color:#9E9E9E;
font-size: 28rpx;
margin-top:10rpx;
}
.beizhu{
color:#9E9E9E;
font-size: 24rpx;
}
\ No newline at end of file
... ...
// pages/orderdetail/orderdetail.js
const app = getApp()
Page({
/**
* 页面的初始数据
*/
data: {
totalmoney: 0,
orderlist: [],
morenaddress: '',
customer_id: '',
order_id: [],
amount: [],
prepage:'',
que:1
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function(options) {
},
//获取订单列表
getorderlist() {
let that = this;
let url = 'index/getOrderList';
app.post(url, '', 'get').then((res) => {
console.log(res);
that.setData({
orderlist: res.data,
totalmoney: res.total_price.toFixed("2")
})
let neworderlist = that.data.orderlist;
let orderid = [];
let goodnum = [];
for (var obj of neworderlist) {
orderid.push(obj.id);
goodnum.push(obj.amount)
}
that.setData({
order_id: orderid,
amount: goodnum
})
}).catch((err) => {
})
},
//进入客户列表页面
gokehu(){
wx.navigateTo({
url: '/pages/mykehu/mykehu',
})
},
//获取默认地址
getmorenaddress() {
let that = this;
let url = 'user/getCustomerList';
let param = {
page: 1,
is_default: 1
}
app.post(url, param, 'get').then((res) => {
console.log(res);
that.setData({
morenaddress: res[0],
customer_id: res[0].id
})
}).catch((err) => {
})
},
//输入折扣率
enterzhekou(e) {
if (e.detail.value > 1) {
wx.showToast({
title: '请输入0-1之间的数字',
icon: 'none'
})
} else {
let totalqian=0;
let id = e.currentTarget.dataset.id;
let neworderlist = this.data.orderlist;
for (var obj of neworderlist) {
if (obj.goods_id == id) {
obj.discount = e.detail.value;
//let dis_price = Number(obj.price) *Number(obj.amount)* Number(e.detail.value);
let dis_price = Number(obj.price)*Number(e.detail.value);
obj.dis_price = dis_price.toFixed("2");
}
totalqian = totalqian + Number(obj.dis_price)*Number(obj.amount);
}
totalqian = totalqian.toFixed("2")
this.setData({
orderlist: neworderlist,
totalmoney: totalqian
})
wx.setStorageSync("orderarr", neworderlist)
}
},
//输入折扣价格
enterzhekouprice(e) {
let id = e.currentTarget.dataset.id;
let neworderlist = this.data.orderlist;
let totalqian = 0;
for (var obj of neworderlist) {
if (obj.goods_id == id) {
obj.dis_price = e.detail.value;
let zhekou=Number(e.detail.value)/Number(obj.price);
zhekou=zhekou.toFixed("2");
obj.discount=zhekou;
}
totalqian = totalqian + Number(obj.dis_price)*Number(obj.amount);
}
this.setData({
orderlist: neworderlist,
totalmoney: totalqian
})
wx.setStorageSync("orderarr", neworderlist)
console.log(this.data.orderlist)
},
//输入开发票名称
enterfaname(e) {
let id = e.currentTarget.dataset.id;
let neworderlist = this.data.orderlist;
for (var obj of neworderlist) {
if (obj.goods_id== id) {
obj.invoice_name = e.detail.value
}
}
this.setData({
orderlist: neworderlist
})
wx.setStorageSync("orderarr", neworderlist)
},
//输入备注
entermark(e) {
let id = e.currentTarget.dataset.id;
let neworderlist = this.data.orderlist;
for (var obj of neworderlist) {
if (obj.goods_id == id) {
obj.mark = e.detail.value
}
}
this.setData({
orderlist: neworderlist
})
wx.setStorageSync("orderarr", neworderlist)
},
//确定提交订单
quedingti() {
let that=this;
console.log(that.data.customer_id)
if (that.data.customer_id==''){
wx.showToast({
title: '请选择地址',
icon:'none'
})
return false
}
let neworderlist = this.data.orderlist;
for (var obj of neworderlist) {
if (obj.discount == '') {
wx.showToast({
title: '请把折扣率填写完整',
icon: 'none'
})
return false
} else if (obj.dis_price == '') {
wx.showToast({
title: '请把折扣率填写完整',
icon: 'none'
})
return false
} else if (obj.invoice_name==''){
wx.showToast({
title: '请把开发票品名填写完整',
icon: 'none'
})
return false
}
}
that.setData({
que:""
})
let newdiscount = [];
let newdis_price = [];
let newinvoice_name = [];
let newmark = [];
for (var obj of neworderlist) {
console.log(obj.mark)
newdiscount.push(obj.discount);
newdis_price.push(obj.dis_price);
newinvoice_name.push(obj.invoice_name);
newmark.push(obj.mark)
}
if (newmark.length==0){
newmark=''
}else{
for(var i=0;i<newmark.length;i++){
if (newmark[i]==''){
newmark[i]=0
}
}
}
console.log(newmark)
let url = 'index/confirmOrder';
let param = {
customer_id: that.data.customer_id,
goods_id: that.data.order_id.join(","),
amount: that.data.amount.join(","),
discount: newdiscount.join(","),
dis_price: newdis_price.join(","),
invoice_name: newinvoice_name.join(","),
mark: newmark.join(",")
}
console.log(param)
app.post(url, param, 'post').then((res) => {
console.log(res);
// wx.showToast({
// title: '提交成功',
// icon: "none"
// })
wx.setStorageSync('orderarr', '');
wx.setStorageSync('total_price', '');
// wx.clearStorage("orderarr");
// wx.clearStorage("total_price");
that.clearcart()
setTimeout(function(){
wx.navigateTo({
url: '/pages/myorder/myorder',
})
},200)
}).catch((err) => {
console.log(err)
})
},
//提交订单清除购物车
clearcart() {
let that = this;
let newcartidarr = this.data.order_id;
let url = 'index/delCar';
let param = {
goods_id: newcartidarr.join(","),
}
app.post(url, param, 'get').then((res) => {
console.log(res);
}).catch((err) => {
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function() {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function() {
let that=this;
let xinorderlist=wx.getStorageSync("orderlist");
console.log('000888', xinorderlist)
// if (xinorderlist!=''){
// this.setData({
// orderlist:xinorderlist
// })
// }
let neworderlist = wx.getStorageSync("orderarr");
let newtotal_price = wx.getStorageSync("total_price")
console.log(neworderlist)
let orderid = [];
let goodnum = [];
for (var obj of neworderlist) {
console.log('00099978', typeof(obj.dis_price));
obj.dis_price = Number(obj.dis_price)
obj.dis_price=obj.dis_price.toFixed("2")
orderid.push(obj.goods_id);
goodnum.push(obj.amount)
}
that.setData({
orderlist:neworderlist,
totalmoney: newtotal_price,
order_id: orderid,
amount: goodnum
})
let pages = getCurrentPages();
let currPage = pages[pages.length - 1]; //当前页面
if (currPage.data.prepage==1){
this.setData({
morenaddress: currPage.data.morenaddress,
customer_id: currPage.data.morenaddress.id
})
}else{
this.getmorenaddress();
}
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function() {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function() {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function() {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function() {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function() {
}
})
\ No newline at end of file
... ...
{
"usingComponents": {}
}
\ No newline at end of file
... ...
<view class='detailhead' bindtap='gokehu'>
<view class="detailzuo">
<view class="detailheadleft">
<image src="/img/address.png"></image>
</view>
<view class="detailmiddle">
<view class="detailtop">
<text class="xingming">{{morenaddress.customer_name}}</text>
<text class="xingmingnum">{{morenaddress.contact_name}}</text>
</view>
<view class="detailaddress">{{morenaddress.receive_name}} {{morenaddress.mobile}}</view>
</view>
</view>
<view class="detailright">
<image src="/img/jiantou2.png"></image>
</view>
</view>
<view class="wuliaobox">
<view class="detailbox" wx:for="{{orderlist}}" wx:key="">
<view class="detailboxname wuliaobian">
{{item.number}}
</view>
<view class="goodname wuliaobian">{{item.name}}</view>
<view class="goodshu wuliaobian">
<view class="goodshuleft">¥{{item.price}}</view>
<view class="goodshuright">x{{item.amount}}</view>
</view>
<view class="shuruzhekou wuliaobian">
<view class="enterzhe">输入折扣率</view>
<view class="enterzhenum">
<input placeholder='请输入折扣率' bindinput="enterzhekou" value="{{item.discount}}" data-id="{{item.goods_id}}"/>
</view>
</view>
<view class="jaige wuliaobian">
<view class="jaigeleft">¥</view>
<view class="jaigeright">
<input placeholder='请输入折扣价格' value="{{item.dis_price}}" type="number" bindinput="enterzhekouprice" data-id="{{item.goods_id}}"/>
</view>
</view>
<view class="jaige wuliaobian">
<view class="jaigeleft">开发票品名</view>
<view class="jaigeright">
<input placeholder='请输入开发票品名' value="{{item.invoice_name}}" bindinput="enterfaname" data-id="{{item.goods_id}}"/>
</view>
</view>
<view class="jaige beizhu">
<view class="jaigeleft">自由文本:</view>
<view class="jaigeright">
<input placeholder='Abcam产品请输入规格' value="{{item.mark}}" bindinput="entermark" data-id="{{item.goods_id}}"/>
</view>
</view>
</view>
</view>
<view class="footbox">
<view class="footboxhead">
总金额:¥{{totalmoney}}
</view>
<view class="quding" bindtap="quedingti" wx:if="{{que==1}}">确定</view>
<view class="quding" wx:else>确定</view>
</view>
\ No newline at end of file
... ...
page{
background: #F5F5FA;
}
.detailhead{
display:flex;
align-items: center;
justify-content: space-between;
width:702rpx;
height:141rpx;
background: #fff;
border-radius: 28rpx;
margin:34rpx auto 0;
padding: 0 29rpx;
box-sizing: border-box
}
.detailheadleft{
width:28rpx;
height:32rpx;
font-size: 0;
flex:0 0 auto;
}
.detailaddress{
color:#141414;
font-size: 28rpx;
margin-top:16rpx;
}
.detailmiddle{
margin-left:30rpx;
}
.detailtop{
color:#141414;
font-size: 28rpx;
}
.xingmingnum{
margin-left:61rpx;
}
.detailright{
width:30rpx;
height:46rpx;
font-size: 0
}
.detailzuo{
display:flex;
align-items: center
}
.wuliaobox{
padding-bottom: 180rpx;
}
.detailbox{
width:702rpx;
background: #fff;
border-radius: 28rpx;
margin:27rpx auto 0;
padding: 31rpx 29rpx;
box-sizing: border-box
}
.goodshu{
display:flex;
align-items: center;
justify-content: space-between
}
.shuruzhekou{
display:flex;
align-items: center
}
.enterzhe{
color:#141414;
font-size: 28rpx;
}
.enterzhenum{
color:#9E9E9E;
font-size: 26rpx;
margin-left: 40rpx;
}
.jaige{
display:flex;
align-items: center
}
.jaigeright{
margin-left:30rpx;
}
.jaigeright{
color:#9E9E9E;
font-size: 26rpx;
}
.jaigeleft{
color:#141414;
font-size: 26rpx;
}
.wuliaobian{
padding: 10rpx 0;
border-bottom:1rpx solid #f5f5f5;
}
.detailboxname,.goodname,.goodshu{
color:#141414;
font-size: 28rpx;
}
.enterbeizhu{
height:100rpx;
}
.enterbeizhu textarea{
height:100rpx;
}
.footbox{
position: fixed;
bottom:0;
z-index: 99
}
.footboxhead{
width:750rpx;
display:flex;
align-items: center;
justify-content: flex-end;
background: #E9E9E9;
height:88rpx;
padding: 0 32rpx;
box-sizing: border-box;
color:#141414;
font-size: 28rpx;
}
.quding{
width:750rpx;
height:88rpx;
background: #2781FB;
color:#fff;
font-size: 30rpx;
text-align: center;
line-height: 88rpx;
}
\ No newline at end of file
... ...
// pages/seemore/seemore.js
const app=getApp()
Page({
/**
* 页面的初始数据
*/
data: {
morelist:[],
page:1
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
},
getmorelist(){
let url = 'index/getMoreNoticeList';
let param={
page:this.data.page
}
app.post(url, param, 'get').then((res) => {
console.log(res);
this.setData({
morelist:this.data.morelist.concat(res)
})
}).catch((err) => {
})
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
this.getmorelist()
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
let newpage=this.data.page;
newpage++;
this.setData({
page:newpage
})
this.getmorelist()
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
}
})
\ No newline at end of file
... ...
{
"usingComponents": {}
}
\ No newline at end of file
... ...
<view class="souhead">
<image src='/img/bg_img.png'></image>
</view>
<view class="morebox">
<view class="titlebox" wx:for="{{morelist}}" wx:key="">
<view class="lancolor"></view>
<view class="gonggaobiao">
{{item.title}}
<text class="riqidate">{{item.createtime}}</text>
</view>
<view class="gonggaocontent">
{{item.introduce}}
</view>
</view>
</view>
\ No newline at end of file
... ...