wechat_user_type
liuxiaoyan 8 years ago
commit f2960ba057
  1. 1
      .gitignore
  2. 5
      app.js
  3. 13
      app.json
  4. 0
      app.wxss
  5. BIN
      images/product_show_1.png
  6. 11
      pages/address/address.js
  7. 12
      pages/address/address.wxml
  8. 0
      pages/address/address.wxss
  9. 24
      pages/index/index.js
  10. 12
      pages/index/index.wxml
  11. 0
      pages/index/index.wxss
  12. 22
      pages/show_product/show_product.js
  13. 11
      pages/show_product/show_product.wxml
  14. 0
      pages/show_product/show_product.wxss
  15. 20
      utils/address.js
  16. 0
      utils/product.js

1
.gitignore vendored

@ -0,0 +1 @@
.DS_Store

@ -0,0 +1,5 @@
App({
onLaunch: function () {
}
})

@ -0,0 +1,13 @@
{
"pages":[
"pages/index/index",
"pages/show_product/show_product",
"pages/address/address"
],
"window":{
"backgroundTextStyle":"light",
"navigationBarBackgroundColor": "#fff",
"navigationBarTitleText": "WeChat",
"navigationBarTextStyle":"black"
}
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 3.3 KiB

@ -0,0 +1,11 @@
const address = require('../../utils/address.js')
Page({
formSubmit: function(e) {
address.postAddress(e.detail.value)
console.log('form发生了submit事件,携带数据为:', e.detail.value)
},
formReset: function(e) {
console.log('form发生了reset事件')
}
})

@ -0,0 +1,12 @@
<form bindsubmit="formSubmit" bindreset="formReset">
<view class="section">
<view class="section_title">详细地址</view>
<input name="input" placeholder="输入地址信息" />
</view>
<view class="btn-area">
<button formType="submit">Submit</button>
<button formType="reset">Reset</button>
</view>
</form>

@ -0,0 +1,24 @@
var app = getApp()
Page({
data: { items:
[
{ url: 'aaaa.jpg',
name: 'aaa',
id: 1
},
{
url: 'aaaa.jpg',
name: 'bbb',
id: 2
}
]
},
bindViewTap: function() {
},
onLoad: function() {
var that = this
}
})

@ -0,0 +1,12 @@
<view>
<scroll-view scroll-y="true" height="100%">
<block wx:for="{{items}}" wx:for-item="item">
<navigator url="../show_product/show_product?id={{item.id}}">
<view bindtap="bindViewTap">
<image class="" src="{{item.url}}" background-size="cover"></image>
<text> {{item.name}} </text>
</view>
</navigator>
</block>
</scroll-view>
</view>

@ -0,0 +1,22 @@
const app = getApp()
Page({
data: {
title: '',
id: 0
},
onLoad (params) {
this.data.id = params.id
},
onReady () {
wx.setNavigationBarTitle({ title: this.data.title })
},
bindTapAddress () {
wx.navigateTo({
url: '../address/address'
})
}
})

@ -0,0 +1,11 @@
<view>
<text>{{name}}</text>
<image src="/images/product_show_{{id}}.png" mode="aspectFill"/>
<view wx:if="{{ address.length > 0 }}">
<text bindtap="bindTapAddress">address</text>
</view>
<view wx:else>
<text bindtap="bindTapAddress">address</text>
</view>
</view>

@ -0,0 +1,20 @@
const API_URL = 'https://api.bayekeji.com/v2'
function postAddress (data) {
return new Promise((resolve, reject) => {
wx.request({
method: POST,
url: `${API_URL}/addresses/new`,
data: Object.assign({}, data),
header: { 'Content-Type': 'application/json' },
success: resolve,
fail: reject
})
})
}
module.exports = {
postAddress (data) {
return postAddress(data).then(res => res.data)
}
}
Loading…
Cancel
Save