cleaning code

wechat_user_type
Ge Hao 8 years ago
parent c0730e670e
commit 9048db516a
  1. 36
      pages/address/address.js
  2. 9
      pages/cart/cart.js
  3. 6
      pages/index/index.js
  4. 32
      pages/show_product/show_product.js
  5. 6
      utils/address.js
  6. 2
      utils/address_data.js
  7. 3
      utils/product.js

@ -7,10 +7,10 @@ Page({
receiverName:'',
receiverMobile:'',
arrayProvince: [],
indexProvince: 0,
arrayCity: [],
indexCity: 0,
arrayCounty: [],
indexProvince: 0,
indexCity: 0,
indexCounty: 0
},
@ -22,7 +22,7 @@ Page({
this.setData({
indexProvince: e.detail.value,
arrayCity: arrayCity,
arrayCounty:district.counties(p,c)
arrayCounty: district.counties(p,c)
})
wx.setStorageSync('currentDistrict', [this.data.indexProvince, this.data.indexCity, this.data.indexCounty])
},
@ -38,7 +38,6 @@ Page({
},
bindChangeCounty: function(e) {
var county = this.data.arrayCounty[this.data.indexCounty]
this.setData({
indexCounty: e.detail.value
})
@ -52,25 +51,26 @@ Page({
wx.setStorage({key:'receiverMobile', data: e.detail.value.inputMobile})
wx.navigateBack()
},
formReset: function(e) {
console.log('form 发生了 reset 事件')
},
// formReset: function(e) {
// console.log('form 发生了 reset 事件')
// },
onLoad (params) {
this.setData({'detailAddress': wx.getStorageSync('detailAddress'),
'receiverName': wx.getStorageSync('receiverName'),
'receiverMobile': wx.getStorageSync('receiverMobile')})
var currentDistrict = wx.getStorageSync('currentDistrict') || [0, 0, 0]
var arrayProvince = district.provinces()
this.setData({
indexProvince: currentDistrict[0],
indexCity: currentDistrict[1],
indexCounty: currentDistrict[2],
arrayProvince: arrayProvince
})
var arrayCity = district.cities(arrayProvince[currentDistrict[0]])
this.setData({arrayCity: arrayCity})
var arrayCounty = district.counties(arrayProvince[currentDistrict[0]], arrayCity[currentDistrict[1]])
this.setData({arrayCounty: arrayCounty})
this.setData({
indexProvince: currentDistrict[0],
indexCity: currentDistrict[1],
indexCounty: currentDistrict[2],
arrayProvince: arrayProvince,
arrayCity: arrayCity,
arrayCounty: arrayCounty,
detailAddress: wx.getStorageSync('detailAddress'),
receiverName: wx.getStorageSync('receiverName'),
receiverMobile: wx.getStorageSync('receiverMobile')
})
}
})

@ -79,8 +79,13 @@ Page({
rObj['quantity'] = obj.quantity;
return rObj;
});
product.postBilling({items: cartArray,
address: this.data.address})
product.postBilling({
items: cartArray,
address: this.data.address
}).then(function(result){
})
}
},

@ -1,8 +1,10 @@
var app = getApp()
const product = require('../../utils/product.js')
Page({
data: {items: [], slides: []},
data: {
items: [],
slides: []
},
bindShowProduct: function (e) {
wx.navigateTo({

@ -1,4 +1,3 @@
const app = getApp()
const product = require('../../utils/product.js')
Page({
@ -10,14 +9,15 @@ Page({
product: {}
},
onShow () {
},
onLoad (params) {
var that = this
this.data.id = params.id
that.data.product = wx.getStorageSync('products').find(function(i){
return i.id === that.data.id
var id = params.id
var product = wx.getStorageSync('products').find(function(i){
return i.id === id
})
this.setData({
id:id,
product:product
})
},
@ -26,25 +26,23 @@ Page({
},
bindAddToCart (e) {
var that = this
var cartItems = wx.getStorageSync('cartItems') || []
var exist = cartItems.find(function(ele){
return ele.id === app.getCurrentPage().data.id
return ele.id === that.data.id
})
if (exist) {
exist.quantity = this.data.quantity
} else {
// var model = getApp().jsonModel
// var product = new model('products', this.data.id)
// product.setAttribute('quantity', this.data.quantity)
var product = {id: this.data.id,
quantity: this.data.quantity,
product: this.data.product}
cartItems.push(product)
cartItems.push({
id: this.data.id,
quantity: this.data.quantity,
product: this.data.product
})
}
this.setData({ toastAddProduct:false });
wx.setStorage({
key: 'cartItems',
data: cartItems

@ -26,11 +26,7 @@ function getLocation () {
success: function(res) {
var latitude = res.latitude
var longitude = res.longitude
wx.openLocation({
latitude: latitude,
longitude: longitude,
scale: 28
})
// TODO
}
})
}

File diff suppressed because one or more lines are too long

@ -41,9 +41,6 @@ module.exports = {
getProducts () {
return getProducts()
},
getProduct (data) {
return getProducts(data)
},
getSlides () {
return getSlides()

Loading…
Cancel
Save