commit
f2960ba057
16 changed files with 131 additions and 0 deletions
@ -0,0 +1 @@ |
||||
.DS_Store |
@ -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" |
||||
} |
||||
} |
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…
Reference in new issue