Compare commits

...

13 Commits

Author SHA1 Message Date
Kiyan
8d8f0f7c5f fix issue 地址选择页面删除操作无效 2017-06-08 11:31:43 +08:00
Kiyan
9dfa21bfdd 重新提示用户授权地理位置和用户信息 2017-06-08 11:25:42 +08:00
Kiyan
d6ae812e27 fix issue update address 2017-06-08 10:08:48 +08:00
Kiyan
87a1eac740 跳转新增地址 2017-06-08 09:52:42 +08:00
Kiyan
d7737a9fe1 fix issue textarea value not work 2017-06-02 10:01:46 +08:00
Kiyan
a6a65c8107 fix 订单详情商店链接 2017-05-31 14:50:44 +08:00
Kiyan
acbfb9d567 fix 选择用户地址 2017-05-31 14:36:05 +08:00
Kiyan
28c4297e80 优化 获取用户地址 2017-05-31 08:54:45 +08:00
Kiyan
d65fdc8f92 添加 订单备注 2017-05-26 15:27:39 +08:00
Kiyan
d3bd6d248d Merge branch 'master' of 122.228.244.120:ipaotui-mall 2017-05-19 08:59:37 +08:00
Kiyan
b4c57a5ebf 商店休息中 2017-05-19 08:58:58 +08:00
Kiyan Gauss
4e2a875fa5 add readme 2017-05-17 16:55:35 +08:00
Kiyan
35c74b7fa7 add screenshot 2017-05-17 16:40:47 +08:00
28 changed files with 371 additions and 40 deletions

0
.gitignore vendored Normal file
View File

21
LICENSE Normal file
View File

@ -0,0 +1,21 @@
MIT License
Copyright (c) 2017 Kiyan
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.

View File

@ -1 +1,47 @@
#ipaotui-mall
# 微信小程序-爱跑腿外卖
## 配置
### 接口域名切换, 默认为正式接口域名
```javascript
// 测试域名
wx.setStorageSync('debug', true)
// 正式域名
wx.removeStorageSync('debug')
```
### request合法域名
```text
https://apis.map.qq.com
https://api.ipaotui.com
https://apitest.ipaotui.com
```
## 预览
### 首页
![index](/images/index.png)
### 商店详情
![shop](/images/shop.png)
### 订单列表
![order list](/images/order-list.png)
### 订单详情
![order show](/images/order-show.png)
### 我的
![mine](/images/mine.png)
### 小程序二维码
![qrcode](/images/gh_d4b22dcbcbad_430.jpg)

View File

@ -43,18 +43,16 @@ App({
}
getCurrentAddress(address => {
address = that.setCurrentAddress(address)
cb(address)
this.getLoginInfo(loginInfo => {
if (loginInfo.is_login) {
this.findNearbyUserAddr(userAddress => {
if (userAddress) {
address = userAddress
if (!userAddress) {
return
}
address = that.setCurrentAddress(address)
cb(address)
that.setCurrentAddress(userAddress)
})
} else {
address = that.setCurrentAddress(address)
cb(address)
}
})
})

View File

@ -1,16 +1,17 @@
{
"pages": [
"pages/index/index",
"pages/order/show",
"pages/order/quasi",
"pages/mine/coupon",
"pages/shop/show",
"pages/address/select",
"pages/mine/mine",
"pages/order/quasi",
"pages/order/show",
"pages/shop/show",
"pages/order/list",
"pages/order/content",
"pages/mine/coupon",
"pages/order/review",
"pages/index/search",
"pages/index/category",
"pages/address/select",
"pages/address/list",
"pages/index/address",
"pages/address/add",

View File

@ -53,6 +53,14 @@ Page({
})
wx.hideNavigationBarLoading()
cb && cb()
if(data.length === 0) {
wx.navigateTo({
url: '/pages/address/add',
success: function(res) {},
fail: function(res) {},
complete: function(res) {},
})
}
},
error() {
that.setData({

View File

@ -12,6 +12,12 @@
<view class="grey-color">
{{item.addr}} {{item.detail}}
</view>
<view class="address-actions">
<navigator url="/pages/address/add?id={{item.addr_id}}&callback=callback" class="address-actions__item">
<image class="address-actions__item-img" src="/images/address_edit_white.png">
</image>
</navigator>
</view>
</view>
</view>
</view>

View File

@ -1 +1,3 @@
{}
{
"navigationBarTitleText": "选择地址"
}

View File

@ -1,7 +1,38 @@
<import src="/templates/star-rate.wxml" />
<template name="shop">
<navigator url="/pages/shop/show?id={{seller_id}}" class="weui-media-box weui-media-box_appmsg shop__item" hover-class="weui-cell_active">
<view wx:if="{{is_rest == 1}}" class="weui-media-box weui-media-box_appmsg shop__item">
<view class="weui-media-box__hd weui-media-box__hd_in-appmsg">
<image class="weui-media-box__thumb" src="{{pic_url}}" />
<view class="shop__rest">休息中</view>
</view>
<view class="weui-media-box__bd weui-media-box__bd_in-appmsg">
<view class="weui-media-box__title">{{seller_name}}</view>
<view class="weui-media-box__desc shop__desc">
<view class="shop__sales">
<view class="shop__star">
<template is="star-rate" data="{{value: overall}}" />
</view>
<view>月售 {{sales}} 单</view>
</view>
<view class="shop__misc weui-flex">
<view class="shop__fee weui-flex__item">
起送 ¥{{min_price}}
</view>
<text class="shop__reach-time grey-color">{{distanceFormat}}km</text> |
<text class="shop__reach-time primary-color">{{reach_time}}分钟</text>
</view>
</view>
<view wx:if="{{promotion.length > 0}}" class="shop__promotion">
<view wx:for="{{promotion}}" wx:key="index" class="shop__promotion-item">
<image class="shop__promotion-icon" src="{{item.pic_url}}"></image>
{{item.info}}
</view>
</view>
</view>
</view>
<navigator wx:else url="/pages/shop/show?id={{seller_id}}" class="weui-media-box weui-media-box_appmsg shop__item" hover-class="weui-cell_active">
<view class="weui-media-box__hd weui-media-box__hd_in-appmsg">
<image class="weui-media-box__thumb" src="{{pic_url}}" />
</view>

View File

@ -1,5 +1,20 @@
@import '/templates/star-rate.wxss';
.weui-media-box__hd {
position: relative;
}
.shop__rest {
position: absolute;
bottom: 0;
left: 0;
width: 100%;
line-height: 1.5;
color: #fff;
font-size: 0.8em;
background-color: #999;
}
.shop__item {
align-items: flex-start;
background-color: #fff;

103
app/pages/order/content.js Normal file
View File

@ -0,0 +1,103 @@
// pages/order/content.js
import {
getPrevPage
} from '../../utils/util'
const limit = 50
Page({
/**
* 页面的初始数据
*/
data: {
limit,
content: ''
},
/**
* 生命周期函数--监听页面加载
*/
onLoad: function (options) {
this.callback = options.callback || 'callback'
var content = options.content
var that = this
if (content) {
// fix textarea value not work
setTimeout(function () {
that.setData({
content
})
}, 200)
}
},
/**
* 生命周期函数--监听页面初次渲染完成
*/
onReady: function () {
},
/**
* 生命周期函数--监听页面显示
*/
onShow: function () {
},
/**
* 生命周期函数--监听页面隐藏
*/
onHide: function () {
},
/**
* 生命周期函数--监听页面卸载
*/
onUnload: function () {
},
/**
* 页面相关事件处理函数--监听用户下拉动作
*/
onPullDownRefresh: function () {
},
/**
* 页面上拉触底事件的处理函数
*/
onReachBottom: function () {
},
/**
* 用户点击右上角分享
*/
onShareAppMessage: function () {
},
onContentInput(e) {
var {value} = e.detail
var {content} = this.data
if (value.length <= limit) {
this.setData({
content: value
})
} else {
this.setData({
content
})
}
},
onSaveTap(e) {
var {content} = this.data
var cb = getPrevPage()[this.callback]
cb && cb(content)
wx.navigateBack({
delta: 1,
})
}
})

View File

@ -0,0 +1,3 @@
{
"navigationBarTitleText": "附加信息"
}

View File

@ -0,0 +1,15 @@
<!--pages/order/content.wxml-->
<view class="weui-cells weui-cells_after-title">
<view class="weui-cell">
<view class="weui-cell__bd">
<textarea bindinput="onContentInput" auto-focus="true" value="{{content}}" class="weui-textarea" placeholder="口味, 偏好等要求" style="height: 3.3em" />
<view class="weui-textarea-counter">{{content.length}}/{{limit}}</view>
</view>
</view>
</view>
<view class="button-sp-area">
<button bindtap="onSaveTap" disabled="{{disabled}}" class="weui-btn" type="primary" loading="{{loading}}">
确定
</button>
</view>

View File

@ -0,0 +1 @@
/* pages/order/content.wxss */

View File

@ -5,15 +5,16 @@ import {
} from '../../utils/apis'
import {
alert,
requestPayment, getCurrentPage
} from '../../utils/util'
Page({
data: {
content: ''
},
onLoad: function (options) {
// 页面初始化 options为页面跳转所带来的参数
this.id = options.id || '2825'
this.id = options.id || '2908'
this.loadData()
},
onReady: function () {
@ -116,17 +117,26 @@ Page({
}
})
},
callbackContent(content) {
this.setData({
content
})
},
onAddOrder(e) {
var that = this
var {id} = this
var {loading} = this.data
var {loading, content, info} = this.data
if (loading) {
return
}
if (!info.receiver_addr_id) {
return alert('请选择收货地址')
}
this.setData({
loading: true
})
addOrder({
remark: content,
quasi_order_id: id,
success(data) {
var order_id = data['order']['order_id']

View File

@ -10,7 +10,7 @@
</view>
</navigator>
<navigator wx:else url="/pages/address/select?callback=callbackAddress" class=" weui-media-box weui-media-box_text weui-cell__ft_in-access weui-media-box_address primary-color text-large">
选择地址
选择收货地址
</navigator>
</view>
</view>
@ -19,6 +19,7 @@
<view class="weui-cell__bd">支付方式</view>
<view class="">在线支付</view>
</view>
<navigator url="/pages/mine/coupon?id={{info.user_coupon_id}}&callback=callbackCoupon" wx:if="{{info.user_coupon_id}}" class="weui-cell weui-cell_access" hover-class="weui-cell_active">
<view class="weui-cell__bd">红包</view>
<view class="weui-cell__ft_in-access">¥{{info.coupon_money}}</view>
@ -28,6 +29,7 @@
<view class="weui-cell__ft">暂无可用</view>
</view>
</view>
<view class="quasi-goods">
<view class="quasi-goods__hd">
<image class="quasi-goods__img" src="/images/shop-512.png"></image>
@ -75,6 +77,15 @@
</view>
</view>
</view>
<view class="weui-cells">
<navigator url="./content?callback=callbackContent&content={{content}}" class="weui-cell weui-cell_access" hover-class="weui-cell_active">
<view class="weui-cell__bd weui-cell__bd_content">备注</view>
<view>{{content}}</view>
<view class="weui-cell__ft weui-cell__ft_in-access">{{content ? '' : '口味, 偏好等要求'}}</view>
</navigator>
</view>
</view>
<view class="quasi-actions">
<view class="quasi-actions__cut">已优惠¥{{info.cut_money_total}}</view>

View File

@ -7,6 +7,9 @@
.weui-media-box_address::after {
right: 15px;
}
.weui-cell__bd_content {
min-width: 4em;
}
/* quasi-goods */

View File

@ -24,7 +24,7 @@ Page({
},
onLoad: function (options) {
// 页面初始化 options为页面跳转所带来的参数
this.id = options.id || 1488
this.id = options.id || 1497
this.loadData()
},
onReady: function () {

View File

@ -1,11 +1,10 @@
<!--pages/order/show.wxml-->
<view class="order-show-tab tab">
<view class="tab__navbar">
<view bindtap="navChange" id="{{index}}" wx:for="{{tabNavs}}" wx:key="{{index}}" class="tab__navbar-item {{index == activeNavIndex? 'tab__navbar-item_active': ''}} ">
订单状态
</view>
<view bindtap="onPhoneTap" class="phone">
<view bindtap="onPhoneTap" class="phone">
<image class="phone__icon" src="/images/chat_phone_normal.png"></image>
</view>
</view>
@ -33,10 +32,10 @@
<view class="weui-cells__title">订单详情</view>
<view class="quasi-goods">
<view class="quasi-goods__hd weui-flex">
<navigator url="/pages/shop/show?id={{info.seller_id}}" class=" trangle">
<view>
<image class="quasi-goods__img" src="/images/shop-512.png"></image>
{{info.seller_name}}
</navigator>
</view>
<view class=" weui-flex__item"></view>
<view class="grey-color">爱跑腿专送</view>
</view>
@ -110,6 +109,7 @@
</view>
</view>
</view>
<view class="weui-cell">
<view class="weui-cell__hd">
配送服务
@ -118,6 +118,14 @@
爱跑腿专送
</view>
</view>
<view class="weui-cell">
<view class="weui-cell__hd">
备注
</view>
<view class="weui-cell__bd">
{{info.remark || '无'}}
</view>
</view>
</view>
<view class="weui-cells__title">订单信息</view>
<view class="weui-cells weui-cells_after-title">

View File

@ -87,14 +87,20 @@ export function login(options) {
} = options
wx.login({
success(res) {
fetch({
url: 'index.php?m=Api&c=WeixinMall&a=login',
data: {
phone, code,
wx_code: res['code'],
session_3rd: wx.getStorageSync('session_3rd')
},
success, error
getApp().getCurrentAddress(address => {
fetch({
url: 'index.php?m=Api&c=WeixinMall&a=login',
data: {
phone, code,
wx_code: res['code'],
session_3rd: wx.getStorageSync('session_3rd'),
city_id: address.city_id,
city_name: address.city,
district_id: address.district_id,
district_name: address.district,
},
success, error
})
})
},
error(res) {
@ -251,7 +257,7 @@ export function updateUserAddr(options) {
city_id: address.city_id,
city_name: address.city,
district_id: address.district_id,
district_name: address.district_name,
district_name: address.district,
},
success, error
})
@ -397,7 +403,7 @@ export function updateOrderCoupon(options) {
// 添加订单
export function addOrder(options) {
var {
quasi_order_id,
quasi_order_id, remark,
success, error
} = options
getApp().getLoginInfo(loginInfo => {
@ -409,7 +415,7 @@ export function addOrder(options) {
url: 'index.php?m=Mall&c=Order&a=addOrder',
data: {
user_id, user_token,
quasi_order_id
quasi_order_id, remark
},
success, error
})

View File

@ -57,7 +57,28 @@ export function getCurrentAddressList(options) {
},
fail(res) {
console.log(res.errMsg)
alert('获取用户地址失败')
if (res.errMsg == 'getLocation:fail auth deny' && wx.openSetting) {
confirm({
content: '若不授权地理位置权限, 则无法正常使用爱跑腿外卖, 请重新授权地理位置权限',
cancelText: '不授权',
confirmText: '授权',
ok() {
wx.openSetting({
success(res) {
console.log(res)
if (res.authSetting['scope.userLocation']) {
getCurrentAddressList(options)
} else {
alert('获取用户地址失败')
}
}
})
}
})
} else {
alert('获取用户地址失败')
}
}
})
}
@ -201,14 +222,15 @@ export function alert(content, callback) {
// 确认框
export function confirm(options) {
var {
content, confirmText,
content, confirmText, cancelText,
ok,
} = options
confirmText = confirmText || '确定'
cancelText = cancelText || '关闭'
wx.showModal({
content,
confirmText,
cancelText: '关闭',
cancelText,
success(res) {
if (res.confirm) {
ok && ok()
@ -308,7 +330,28 @@ export function getUserInfo(cb) {
},
fail(res) {
console.log(res)
alert('获取用户信息失败')
if (res.errMsg == 'getUserInfo:fail auth deny' && wx.openSetting) {
confirm({
content: '若不授用户信息权限, 则无法正常显示用户头像和昵称, 请重新授权用户信息权限',
cancelText: '不授权',
confirmText: '授权',
ok() {
wx.openSetting({
success(res) {
console.log(res)
if (res.authSetting['scope.userInfo']) {
getUserInfo(cb)
} else {
alert('获取用户信息失败')
}
}
})
}
})
} else {
alert('获取用户信息失败')
}
}
})
}

Binary file not shown.

After

Width:  |  Height:  |  Size: 81 KiB

BIN
images/index.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 384 KiB

BIN
images/mine.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 146 KiB

BIN
images/order-list.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 341 KiB

BIN
images/order-show.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 155 KiB

BIN
images/select-address.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 144 KiB

BIN
images/shop.png Normal file

Binary file not shown.

After

Width:  |  Height:  |  Size: 485 KiB