wechat_user_type
liuxiaoyan 8 years ago
parent fffde2fda1
commit e7193773b9
  1. 12
      pages/address/address.js
  2. 18
      pages/address/address.wxml
  3. 3
      pages/index/index.js
  4. 2
      pages/show_product/show_product.js
  5. 9
      pages/show_product/show_product.wxml

@ -1,6 +1,18 @@
const address = require('../../utils/address.js')
Page({
data: {
arraySheng: ['美国', '中国', '巴西', '日本'],
indexSheng: 0,
},
bindPickerChange: function(e) {
console.log('picker发送选择改变,携带值为', e.detail.value)
this.setData({
indexSheng: e.detail.value
})
},
formSubmit: function(e) {
address.postAddress(e.detail.value)
console.log('form 发生了 submit 事件,携带数据为:', e.detail.value)

@ -1,10 +1,20 @@
<form bindsubmit="formSubmit" bindreset="formReset">
<view>
<view class="section">
<view class="section__title">省</view>
<picker bindchange="bindPickerChange" value="{{indexSheng}}" range="{{arraySheng}}">
<view class="picker">
当前选择:{{arraySheng[indexSheng]}}
</view>
</picker>
</view>
<view>
<view class="section">
<view class="section__title">市</view>
<picker bindchange="bindPickerChange" value="{{index}}" range="{{array}}">
<view class="picker">
当前选择:{{array[index]}}
</view>
</picker>
</view>
<view>

@ -4,9 +4,6 @@ const product = require('../../utils/product.js')
Page({
data: {items: []},
bindViewTap: function() {
},
onLoad: function() {
var that = this

@ -20,7 +20,6 @@ Page({
wx.getNetworkType({
success: function(res) {
var networkType = res.networkType // 返回网络类型2g,3g,4g,wifi
debugger
if (networkType) {
product.getProduct(params.id).then(function(result) {
console.log(result)
@ -51,6 +50,7 @@ Page({
},
formSubmit: function(e) {
e.detail.value['sku'] = e.target.dataset['sku']
// address.postBuyProduct(e.detail.value)
console.log('form发生了submit事件,携带数据为:', e.detail.value)
},

@ -1,6 +1,6 @@
<view>
<text>{{product.attributes.name}}</text>
<image src="{{product.attributes['image-url']}}" mode="aspectFill"/>
<text>{{product.attributes.name}}</text>
<view wx:if="{{ address > 0 }}" bindtap="bindTapAddress">
<text>{{address}}</text>
@ -11,16 +11,13 @@
</view>
<view>
<form bindsubmit="formSubmit" bindreset="formReset">
<form bindsubmit="formSubmit" bindreset="formReset" data-sku="{{product.attributes.sku}}">
<view class="section">
<text class="">数量</text>
<input name="quantity" value="1" />
</view>
<view class="section">
<text type="hidden">sku:{{product.attributes.sku || '无法获取sku'}}</text>
</view>
<view class="section">
<text>{{product.attributes.price || '无法获取价格'}}</text>
<text>¥{{product.attributes.price || '无法获取价格'}}</text>
</view>
<view class="btn-area">
<button formType="submit">buy it!</button>

Loading…
Cancel
Save