提交 667901a9 编写于 作者: D devil_gong

头条小程序优化

上级 c73aa75a
......@@ -92,7 +92,7 @@ class User extends Common
}
// 授权
$result = (new \base\AlipayAuth())->GetAuthCode(MyC('common_app_mini_alipay_appid'), $this->data_post['authcode']);
$result = (new \base\AlipayAuth())->GetAuthSessionKey(MyC('common_app_mini_alipay_appid'), $this->data_post['authcode']);
if($result['status'] == 0)
{
// 先从数据库获取用户信息
......@@ -326,10 +326,17 @@ class User extends Common
'appid' => MyC('common_app_mini_toutiao_appid'),
'secret' => MyC('common_app_mini_toutiao_appsecret'),
];
$result = (new \base\Toutiao())->GetAuthCode($this->data_post);
$result = (new \base\Toutiao())->GetAuthSessionKey($this->data_post);
if($result['status'] == 0)
{
return DataReturn('授权登录成功', 0, $result['data']['openid']);
// 先从数据库获取用户信息
$user = UserService::AppUserInfoHandle(null, 'toutiao_openid', $result);
if(empty($user))
{
return DataReturn('授权登录成功', 0, ['is_alipay_user_exist'=>0, 'openid'=>$result['data']]);
}
$user['is_alipay_user_exist'] = 1;
return DataReturn('授权登录成功', 0, $user);
}
return DataReturn($result['msg'], -10);
}
......
......@@ -18,7 +18,12 @@ namespace base;
class AlipayAuth
{
/**
* [GetAuthCode 获取用户授权信息]
* [__construct 构造方法]
*/
public function __construct(){}
/**
* [GetAuthSessionKey 获取用户授权信息]
* @author Devil
* @blog http://gong.gg/
* @version 1.0.0
......@@ -27,7 +32,7 @@ class AlipayAuth
* @param [string] $authcode [用户授权码]
* @return [array|boolean] [失败false, 用户授权信息]
*/
public function GetAuthCode($app_id, $authcode = '')
public function GetAuthSessionKey($app_id, $authcode = '')
{
if(empty($app_id) || empty($authcode))
{
......@@ -70,11 +75,6 @@ class AlipayAuth
return ['status'=>-1, 'msg'=>$msg];
}
/**
* [__construct 构造方法]
*/
public function __construct(){}
/**
* [GetParamSign 生成参数和签名]
* @param [array] $data [待生成的参数]
......
此差异已折叠。
......@@ -31,7 +31,7 @@ class Toutiao
* @desc description
* @param [array] $params [输入参数]
*/
public function GetAuthCode($params = [])
public function GetAuthSessionKey($params = [])
{
if(empty($params['authcode']))
{
......@@ -49,7 +49,7 @@ class Toutiao
{
return ['status'=>-1, 'msg'=>$result['errmsg']];
}
return ['status'=>0, 'msg'=>'授权成功', 'data'=>$result];
return ['status'=>0, 'msg'=>'授权成功', 'data'=>$result['openid']];
}
/**
......
......@@ -34,7 +34,6 @@ Page({
goods_video_is_autoplay: false,
common_app_is_use_mobile_detail: 1,
popup_share_status: false,
common_app_is_online_service: 0,
// 限时秒杀插件
......@@ -697,16 +696,6 @@ Page({
this.setData({ goods_video_is_autoplay: false });
},
// 分享开启弹层
popup_share_event(e) {
this.setData({ popup_share_status: true });
},
// 分享弹层关闭
popup_share_close_event(e) {
this.setData({ popup_share_status: false });
},
// 显示秒杀插件-倒计时
plugins_limitedtimediscount_countdown() {
// 销毁之前的任务
......
......@@ -67,7 +67,7 @@ App({
// 请求地址
request_url: "{{request_url}}",
// request_url: 'http://tp5-dev.com/',
request_url: 'http://tp5-dev.com/',
// request_url: 'https://test.shopxo.net/',
// 基础信息
......@@ -154,6 +154,24 @@ App({
);
},
/**
* 获取用户信息,信息不存在则唤醒授权
* object 回调操作对象
* method 回调操作对象的函数
* return 有用户数据直接返回, 则回调调用者
*/
get_user_info(object, method) {
var user = this.get_user_cache_info();
if (user == false) {
// 唤醒用户授权
this.user_login(object, method);
return false;
} else {
return user;
}
},
/**
* 从缓存获取用户信息
*/
......@@ -195,38 +213,82 @@ App({
* method 回调操作对象的函数
*/
user_login(object, method) {
var self = this;
tt.login({
success: (res) => {
if (res.code) {
tt.request({
url: self.get_request_url('toutiaouserauth', 'user'),
method: 'POST',
data: { authcode: res.code, anonymous_code: res.anonymousCode },
dataType: 'json',
header: { 'content-type': 'application/x-www-form-urlencoded' },
success: (res) => {
if (res.data.code == 0) {
tt.setStorage({
key: self.data.cache_user_login_key,
data: res.data.data
});
self.get_user_login_info(object, method, res.data.data);
} else {
var openid = tt.getStorageSync(this.data.cache_user_login_key) || null;
if (openid == null)
{
var self = this;
// 加载loding
tt.showLoading({ title: "授权中..." });
tt.login({
success: (res) => {
if (res.code) {
tt.request({
url: self.get_request_url('toutiaouserauth', 'user'),
method: 'POST',
data: { authcode: res.code, anonymous_code: res.anonymousCode },
dataType: 'json',
header: { 'content-type': 'application/x-www-form-urlencoded' },
success: (res) => {
tt.hideLoading();
self.showToast(res.data.msg);
}
},
fail: () => {
tt.hideLoading();
self.showToast('服务器请求出错');
},
if (res.data.code == 0) {
var data = res.data.data;
if ((data.is_alipay_user_exist || 0) == 1) {
tt.setStorage({
key: self.data.cache_user_info_key,
data: data,
success: (res) => {
if (typeof object === 'object' && (method || null) != null) {
object[method]();
}
},
fail: () => {
self.showToast('用户信息缓存失败');
}
});
} else {
tt.setStorage({
key: self.data.cache_user_login_key,
data: data.openid
});
self.login_to_auth();
}
} else {
self.showToast(res.data.msg);
}
},
fail: () => {
tt.hideLoading();
self.showToast('服务器请求出错');
},
});
}
},
fail: (e) => {
tt.hideLoading();
self.showToast('授权失败');
}
});
} else {
this.login_to_auth();
}
},
/**
* 跳转到登录页面授权
*/
login_to_auth() {
tt.showModal({
title: '温馨提示',
content: '授权用户信息',
confirmText: '确认',
cancelText: '暂不',
success: (result) => {
if (result.confirm) {
tt.navigateTo({
url: "/pages/login/login"
});
}
},
fail: (e) => {
tt.hideLoading();
self.showToast('授权失败');
}
});
},
......@@ -582,6 +644,36 @@ App({
});
},
// 位置权限获取
location_authorize(object, method, params) {
var self = this;
tt.getSetting({
success(res) {
if (!res.authSetting['scope.userLocation']) {
tt.authorize({
scope: 'scope.userLocation',
success (res) {
if (typeof object === 'object' && (method || null) != null) {
object[method](params);
}
},
fail (res) {
tt.openSetting();
self.showToast('请同意地理位置授权');
}
});
} else {
if (typeof object === 'object' && (method || null) != null) {
object[method](params);
}
}
},
fail: (e) => {
self.showToast("授权校验失败");
}
});
},
// 拨打电话
call_tel(value) {
if ((value || null) != null) {
......@@ -589,24 +681,16 @@ App({
}
},
// 登录校验
is_login_check(res) {
/**
* 登录校验
* object 回调操作对象
* method 回调操作对象的函数
*/
is_login_check(res, object, method) {
if(res.code == -400)
{
tt.clearStorage();
tt.showModal({
title: '温馨提示',
content: '授权用户信息',
confirmText: '确认',
cancelText: '暂不',
success: (result) => {
if (result.confirm) {
tt.navigateTo({
url: "/pages/login/login?event_callback=init"
});
}
},
});
this.get_user_info(object, method);
return false;
}
return true;
......
......@@ -27,7 +27,8 @@
"pages/user-orderaftersale/user-orderaftersale",
"pages/user-orderaftersale-detail/user-orderaftersale-detail",
"pages/coupon/coupon",
"pages/user-coupon/user-coupon"
"pages/user-coupon/user-coupon",
"pages/extraction-address/extraction-address"
],
"window": {
"navigationBarTitleText": "{{application_title}}",
......
......@@ -13,13 +13,15 @@ Page({
// 初始化
init() {
var user = app.get_user_cache_info(this, "init");
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=init"
});
return false;
var user = app.get_user_info(this, "init");
if (user != false) {
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=init"
});
return false;
}
}
},
......@@ -60,8 +62,11 @@ Page({
}, 2000);
} else {
this.setData({form_submit_loading: false});
app.showToast(res.data.msg);
if (app.is_login_check(res.data)) {
app.showToast(res.data.msg);
} else {
app.showToast('提交失败,请重试!');
}
}
},
fail: () => {
......
......@@ -8,13 +8,15 @@ Page({
payment_list: [],
goods_list: [],
address: null,
address_id: 0,
address_id: null,
total_price: 0,
user_note_value: '',
is_first: 1,
extension_data: [],
payment_id: 0,
common_order_is_booking: 0,
common_site_type: 0,
extraction_address: [],
// 优惠劵
plugins_coupon_data: null,
......@@ -23,17 +25,9 @@ Page({
popup_plugins_coupon_status: false,
},
onLoad(params) {
if((params.data || null) == null || app.get_length(JSON.parse(params.data)) == 0)
//params['data'] = '{"buy_type":"goods","goods_id":"1","stock":"1","spec":"[]"}';
if((params.data || null) != null && app.get_length(JSON.parse(params.data)) > 0)
{
tt.alert({
title: '温馨提示',
content: '订单信息有误',
buttonText: '确认',
success: () => {
tt.navigateBack();
},
});
} else {
this.setData({ params: JSON.parse(params.data)});
// 删除地址缓存
......@@ -42,13 +36,22 @@ Page({
},
onShow() {
tt.setNavigationBarTitle({title: app.data.common_pages_title.buy});
this.init();
this.setData({is_first: 0});
this.setData({ is_first: 0 });
},
// 获取数据列表
init() {
// 订单参数信息是否正确
if (this.data.params == null) {
this.setData({
data_list_loding_status: 2,
data_list_loding_msg: '订单信息有误',
});
tt.stopPullDownRefresh();
return false;
}
// 本地缓存地址
if(this.data.is_first == 0)
{
......@@ -57,12 +60,7 @@ Page({
{
this.setData({
address: cache_address,
address_id: cache_address.id
});
} else {
this.setData({
address: null,
address_id: 0
address_id: cache_address.id || null,
});
}
}
......@@ -97,6 +95,8 @@ Page({
extension_data: data.extension_data || [],
data_list_loding_status: 3,
common_order_is_booking: data.common_order_is_booking || 0,
common_site_type: data.common_site_type || 0,
extraction_address: data.base.extraction_address || [],
plugins_coupon_data: data.plugins_coupon_data || null,
});
......@@ -113,19 +113,14 @@ Page({
}
// 地址
if (this.data.address == null || this.data.address_id == 0) {
if((data.base.address || null) != null) {
this.setData({
address: data.base.address,
address_id: data.base.address.id,
});
tt.setStorage({
key: app.data.cache_buy_user_address_select_key,
data: data.base.address,
});
}
}
this.setData({
address: data.base.address || null,
address_id: ((data.base.address || null) != null && (data.base.address.id || null) != null) ? data.base.address.id : null,
});
tt.setStorage({
key: app.data.cache_buy_user_address_select_key,
data: data.base.address || null,
});
// 支付方式
this.payment_list_data(data.payment_list);
......@@ -135,7 +130,9 @@ Page({
data_list_loding_status: 2,
data_list_loding_msg: res.data.msg,
});
app.showToast(res.data.msg);
if (app.is_login_check(res.data, this, 'init')) {
app.showToast(res.data.msg);
}
}
},
fail: () => {
......@@ -171,9 +168,11 @@ Page({
data['coupon_id'] = this.data.plugins_use_coupon_id;
// 数据验证
var validation = [
{ fields: 'address_id', msg: '请选择地址' }
];
var validation = [];
if (this.data.common_site_type == 0 || this.data.common_site_type == 2)
{
validation.push({ fields: 'address_id', msg: '请选择地址', is_can_zero: 1 });
}
if (this.data.common_order_is_booking != 1) {
validation.push({ fields: 'payment_id', msg: '请选择支付方式' });
}
......@@ -263,4 +262,21 @@ Page({
this.init();
},
// 地址选择事件
address_event(e) {
if(this.data.common_site_type == 0)
{
tt.navigateTo({
url: '/pages/user-address/user-address?is_back=1'
});
} else if (this.data.common_site_type == 2)
{
tt.navigateTo({
url: '/pages/extraction-address/extraction-address?is_back=1'
});
} else {
app.showToast('当前模式不允许使用地址');
}
},
});
<view tt:if="{{goods_list.length > 0}}" class="page">
<!-- 地址 -->
<view class="address bg-white arrow-right">
<navigator url="/pages/user-address/user-address?is_back=1" hover-class="none">
<view tt:if="{{address != null}}">
<view class="address-base oh">
<text>{{address.name}}</text>
<text class="fr">{{address.tel}}</text>
<block tt:if="{{common_site_type == 1}}">
<import src="/pages/common/nodata.ttml" />
<template is="nodata" data="{{status: 2, msg: '展示型不允许提交订单'}}"></template>
</block>
<block wx:else>
<view tt:if="{{goods_list.length > 0}}" class="page">
<!-- 地址 -->
<block tt:if="{{common_site_type == 0 || common_site_type == 2}}">
<view class="address bg-white arrow-right" bindtap="address_event">
<view tt:if="{{address != null}}">
<view class="address-base oh">
<text tt:if="{{(address.alias || null) != null}}" class="address-alias">{{address.alias}}</text>
<text>{{address.name}}</text>
<text class="fr">{{address.tel}}</text>
</view>
<view class="address-detail oh">
<image class="icon fl" src="/images/user-address.png" mode="widthFix" />
<view class="text fr">{{address.province_name}}{{address.city_name}}{{address.county_name}}{{address.address}}</view>
</view>
</view>
<view class="address-detail oh">
<image class="icon fl" src="/images/user-address.png" mode="widthFix" />
<view class="text fr">{{address.province_name}}{{address.city_name}}{{address.county_name}}{{address.address}}</view>
<view tt:if="{{address == null}}" class="no-address cr-888">
请选择地址
</view>
</view>
<view tt:if="{{address == null}}" class="no-address cr-888">
请选择地址
</view>
</navigator>
</view>
<view class="address-divider spacing-mb"></view>
<view class="address-divider spacing-mb"></view>
</block>
<!-- 商品 -->
<view class="goods bg-white spacing-mb">
<view tt:for="{{goods_list}}" tt:key="key" class="goods-item oh">
<image class="goods-image fl" src="{{item.images}}" mode="aspectFill" />
<view class="goods-base">
<view class="goods-title multi-text">{{item.title}}</view>
<block tt:if="{{item.spec != null}}">
<view class="goods-spec cr-888" tt:for="{{item.spec}}" tt:key="key" tt:for-item="spec">{{spec.type}}:{{spec.value}}
</view>
</block>
</view>
<view class="oh goods-price">
<text class="sales-price">¥{{item.price}}
</text>
<text tt:if="{{item.original_price > 0}}" class="original-price">¥{{item.original_price}}
</text>
<text class="buy-number cr-888">x{{item.stock}}
</text>
<!-- 商品 -->
<view class="goods bg-white spacing-mb">
<view tt:for="{{goods_list}}" tt:key="key" class="goods-item oh">
<image class="goods-image fl" src="{{item.images}}" mode="aspectFill" />
<view class="goods-base">
<view class="goods-title multi-text">{{item.title}}</view>
<block tt:if="{{item.spec != null}}">
<view class="goods-spec cr-888" tt:for="{{item.spec}}" tt:key="key" tt:for-item="spec">{{spec.type}}:{{spec.value}}
</view>
</block>
</view>
<view class="oh goods-price">
<text class="sales-price">¥{{item.price}}
</text>
<text tt:if="{{item.original_price > 0}}" class="original-price">¥{{item.original_price}}
</text>
<text class="buy-number cr-888">x{{item.stock}}
</text>
</view>
</view>
</view>
</view>
<!-- 留言 -->
<view class="content-textarea-view bg-white spacing-mb">
<textarea tt:if="{{!popup_plugins_coupon_status}}" bindinput="bind_user_note_event" value="{{user_note_value}}" maxlength="60" placeholder="留言" class="wh-auto" />
<view tt:if="{{popup_plugins_coupon_status}}" class="cr-888">{{user_note_value || '留言'}}</view>
</view>
<!-- 优惠劵 -->
<view tt:if="{{(plugins_coupon_data || null) != null && plugins_coupon_data.coupon_list.length > 0}}" class="plugins-coupon bg-white spacing-mb arrow-right" bindtap="plugins_coupon_open_event">
<text class="cr-666">优惠劵</text>
<text class="cr-ccc fr">{{plugins_choice_coupon_value}}</text>
</view>
<!-- 留言 -->
<view class="content-textarea-view bg-white spacing-mb">
<textarea tt:if="{{!popup_plugins_coupon_status}}" bindinput="bind_user_note_event" value="{{user_note_value}}" maxlength="60" placeholder="留言" class="wh-auto" />
<view tt:if="{{popup_plugins_coupon_status}}" class="cr-888">{{user_note_value || '留言'}}</view>
</view>
<!-- 扩展数据展示 -->
<view tt:if="{{extension_data.length > 0}}" class="extension-list spacing-mb">
<view tt:for="{{extension_data}}" tt:key="key" class="item oh">
<text class="cr-666 fl">{{item.name}}
</text>
<text class="text-tips fr">{{item.tips}}
</text>
<!-- 优惠劵 -->
<view tt:if="{{(plugins_coupon_data || null) != null && plugins_coupon_data.coupon_list.length > 0}}" class="plugins-coupon bg-white spacing-mb arrow-right" bindtap="plugins_coupon_open_event">
<text class="cr-666">优惠劵</text>
<text class="cr-ccc fr">{{plugins_choice_coupon_value}}</text>
</view>
</view>
<!-- 支付方式 -->
<view tt:if="{{payment_list.length > 0 && common_order_is_booking != 1}}" class="payment-list bg-white oh">
<view class="item tc fl" tt:for="{{payment_list}}" tt:key="key">
<view class="item-content br {{(item.selected || '')}}" data-value="{{item.id}}" bindtap="payment_event">
<image tt:if="{{(item.logo || null) != null}}" class="icon" src="{{item.logo}}" mode="widthFix" />
<text>{{item.name}}</text>
<!-- 扩展数据展示 -->
<view tt:if="{{extension_data.length > 0}}" class="extension-list spacing-mb">
<view tt:for="{{extension_data}}" tt:key="key" class="item oh">
<text class="cr-666 fl">{{item.name}}
</text>
<text class="text-tips fr">{{item.tips}}
</text>
</view>
</view>
</view>
<!-- 导航 -->
<view class="buy-nav oh wh-auto">
<view class="nav-base bg-white fl single-text">
<text>合计:</text>
<text class="sales-price">¥{{total_price}}</text>
<!-- 支付方式 -->
<view tt:if="{{payment_list.length > 0 && common_order_is_booking != 1}}" class="payment-list bg-white oh">
<view class="item tc fl" tt:for="{{payment_list}}" tt:key="key">
<view class="item-content br {{(item.selected || '')}}" data-value="{{item.id}}" bindtap="payment_event">
<image tt:if="{{(item.logo || null) != null}}" class="icon" src="{{item.logo}}" mode="widthFix" />
<text>{{item.name}}</text>
</view>
</view>
</view>
<view class="fr nav-submit">
<button class="bg-main wh-auto" type="default" bindtap="buy_submit_event" disabled="{{buy_submit_disabled_status}}" hover-class="none">提交订单</button>
<!-- 导航 -->
<view class="buy-nav oh wh-auto">
<view class="nav-base bg-white fl single-text">
<text>合计:</text>
<text class="sales-price">¥{{total_price}}</text>
</view>
<view class="fr nav-submit">
<button class="bg-main wh-auto" type="default" bindtap="buy_submit_event" disabled="{{buy_submit_disabled_status}}" hover-class="none">提交订单</button>
</view>
</view>
</view>
</view>
<view tt:if="{{goods_list.length == 0}}">
<import src="/pages/common/nodata.ttml" />
<template is="nodata" data="{{status: data_list_loding_status, msg: data_list_loding_msg}}"></template>
</view>
<view tt:if="{{goods_list.length == 0}}">
<import src="/pages/common/nodata.ttml" />
<template is="nodata" data="{{status: data_list_loding_status, msg: data_list_loding_msg}}"></template>
</view>
<!-- 优惠劵选择 -->
<component-popup prop-show="{{popup_plugins_coupon_status}}" prop-position="bottom" bindonclose="plugins_coupon_close_event">
<view class="plugins-coupon-popup bg-white">
<view class="close oh">
<view class="fr" catchtap="plugins_coupon_close_event">
<icon type="clear" size="20" />
</view>
</view>
<view tt:if="{{(plugins_coupon_data || null) != null && plugins_coupon_data.coupon_list.length > 0}}" class="coupon-container oh br-b">
<view class="not-use-tips tc">
<text bindtap="plugins_coupon_not_use_event">不使用优惠劵</text>
<!-- 优惠劵选择 -->
<component-popup prop-show="{{popup_plugins_coupon_status}}" prop-position="bottom" bindonclose="plugins_coupon_close_event">
<view class="plugins-coupon-popup bg-white">
<view class="close oh">
<view class="fr" catchtap="plugins_coupon_close_event">
<icon type="clear" size="20" />
</view>
</view>
<block tt:for="{{plugins_coupon_data.coupon_list}}" tt:key="item">
<view class="item spacing-mt bg-white" style="border:1px solid {{item.coupon.bg_color_value}};">
<view class="v-left fl">
<view class="base single-text" style="color:{{item.coupon.bg_color_value}};">
<text class="symbol">¥</text>
<text class="price">{{item.coupon.discount_value}}</text>
<text class="unit">{{item.coupon.type_unit}}</text>
<text tt:if="{{(item.coupon.desc || null) != null}}" class="desc cr-888">{{item.coupon.desc}}</text>
<view tt:if="{{(plugins_coupon_data || null) != null && plugins_coupon_data.coupon_list.length > 0}}" class="coupon-container oh br-b">
<view class="not-use-tips tc">
<text bindtap="plugins_coupon_not_use_event">不使用优惠劵</text>
</view>
<block tt:for="{{plugins_coupon_data.coupon_list}}" tt:key="item">
<view class="item spacing-mt bg-white" style="border:1px solid {{item.coupon.bg_color_value}};">
<view class="v-left fl">
<view class="base single-text" style="color:{{item.coupon.bg_color_value}};">
<text class="symbol">¥</text>
<text class="price">{{item.coupon.discount_value}}</text>
<text class="unit">{{item.coupon.type_unit}}</text>
<text tt:if="{{(item.coupon.desc || null) != null}}" class="desc cr-888">{{item.coupon.desc}}</text>
</view>
<view tt:if="{{(item.coupon.use_limit_type_name || null) != null}}" class="base-tips cr-666 single-text">{{item.coupon.use_limit_type_name}}</view>
<view class="base-time cr-888 single-text">{{item.time_start_text}} 至 {{item.time_end_text}}</view>
</view>
<view class="v-right fr" style="background:{{item.coupon.bg_color_value}};" data-index="{{index}}" data-value="{{item.id}}" bindtap="plugins_coupon_use_event">
<text class="circle"></text>
<text>{{plugins_use_coupon_id == item.id ? '已选' : '选择'}}</text>
</view>
<view tt:if="{{(item.coupon.use_limit_type_name || null) != null}}" class="base-tips cr-666 single-text">{{item.coupon.use_limit_type_name}}</view>
<view class="base-time cr-888 single-text">{{item.time_start_text}} 至 {{item.time_end_text}}</view>
</view>
<view class="v-right fr" style="background:{{item.coupon.bg_color_value}};" data-index="{{index}}" data-value="{{item.id}}" bindtap="plugins_coupon_use_event">
<text class="circle"></text>
<text>{{plugins_use_coupon_id == item.id ? '已选' : '选择'}}</text>
</view>
</view>
</block>
</block>
</view>
</view>
</view>
</component-popup>
\ No newline at end of file
</component-popup>
</block>
\ No newline at end of file
......@@ -12,7 +12,7 @@
padding: 10rpx 35rpx 10rpx 10rpx;
}
.address-detail .icon {
width: 35rpx;
width: 30rpx;
height: 35rpx !important;
}
.address-detail .text {
......@@ -30,6 +30,13 @@
height: 85rpx;
line-height: 85rpx;
}
.address-alias {
border: 1px solid #d2364c;
color: #d2364c;
padding: 2rpx 10rpx;
border-radius: 6rpx;
margin-right: 10rpx;
}
/**
* 商品
......
......@@ -22,31 +22,39 @@ Page({
},
init(e) {
var user = app.get_user_cache_info(this, "init");
// 用户未绑定用户则转到登录页面
var msg = (user == false) ? '授权用户信息' : '绑定手机号码';
if (app.user_is_need_login(user)) {
tt.showModal({
title: '温馨提示',
content: msg,
confirmText: '确认',
cancelText: '暂不',
success: (result) => {
if (result.confirm) {
tt.navigateTo({
url: "/pages/login/login?event_callback=init"
});
} else {
this.setData({
data_list_loding_status: 0,
data_bottom_line_status: false,
data_list_loding_msg: '请先' + msg,
});
}
},
});
var user = app.get_user_info(this, "init");
if (user != false) {
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.showModal({
title: '温馨提示',
content: '绑定手机号码',
confirmText: '确认',
cancelText: '暂不',
success: (result) => {
if (result.confirm) {
tt.navigateTo({
url: "/pages/login/login?event_callback=init"
});
} else {
this.setData({
data_list_loding_status: 0,
data_bottom_line_status: false,
data_list_loding_msg: '请绑定手机号码',
});
}
},
});
} else {
this.get_data();
}
} else {
this.get_data();
tt.stopPullDownRefresh();
this.setData({
data_list_loding_status: 0,
data_bottom_line_status: false,
data_list_loding_msg: '请先授权用户信息',
});
}
},
......@@ -87,7 +95,9 @@ Page({
data_bottom_line_status: false,
data_list_loding_msg: res.data.msg,
});
app.showToast(res.data.msg);
if (app.is_login_check(res.data, this, 'get_data')) {
app.showToast(res.data.msg);
}
}
},
fail: () => {
......@@ -173,7 +183,11 @@ Page({
// 选择处理
this.selected_calculate();
} else {
app.showToast(res.data.msg);
if (app.is_login_check(res.data)) {
app.showToast(res.data.msg);
} else {
app.showToast('提交失败,请重试!');
}
}
},
fail: () => {
......@@ -193,7 +207,11 @@ Page({
if (res.data.code == 0) {
this.cart_delete(id, type);
} else {
app.showToast(res.data.msg);
if (app.is_login_check(res.data)) {
app.showToast(res.data.msg);
} else {
app.showToast('提交失败,请重试!');
}
}
},
fail: () => {
......@@ -245,7 +263,11 @@ Page({
app.showToast(((type == 'delete') ? '删除成功' : '收藏成功'), 'success');
} else {
app.showToast((type == 'delete') ? '删除失败' : '收藏失败');
if (app.is_login_check(res.data)) {
app.showToast((type == 'delete') ? '删除失败' : '收藏失败');
} else {
app.showToast('提交失败,请重试!');
}
}
},
fail: () => {
......
......@@ -6,6 +6,10 @@ Page({
data_list_loding_msg: '',
data_list: [],
data_base: null,
// 优惠劵领取
temp_coupon_receive_index: null,
temp_coupon_receive_value: null,
},
onLoad(params) {
......@@ -80,45 +84,59 @@ Page({
// 优惠劵领取事件
coupon_receive_event(e) {
var user = app.get_user_cache_info(this, "coupon_receive_event");
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=coupon_receive_event"
});
return false;
// 参数处理
if((e || null) == null)
{
var index = this.data.temp_coupon_receive_index;
var value = this.data.temp_coupon_receive_value;
} else {
var self = this;
var index = e.currentTarget.dataset.index;
var value = e.currentTarget.dataset.value;
var temp_list = this.data.data_list;
if (temp_list[index]['is_operable'] != 0) {
tt.showLoading({ title: "处理中..." });
tt.request({
url: app.get_request_url("receive", "coupon"),
method: "POST",
data: { "coupon_id": value },
dataType: "json",
header: { 'content-type': 'application/x-www-form-urlencoded' },
success: res => {
tt.hideLoading();
if (res.data.code == 0) {
app.showToast(res.data.msg, "success");
if (self.data.data_base != null && self.data.data_base.is_repeat_receive != 1)
{
temp_list[index]['is_operable'] = 0;
temp_list[index]['is_operable_name'] = '已领取';
self.setData({ data_list: temp_list });
this.setData({temp_coupon_receive_index: index, temp_coupon_receive_value: value});
}
// 登录校验
var user = app.get_user_info(this, 'coupon_receive_event');
if (user != false) {
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.navigateTo({
url: "/pages/login/login?event_callback=coupon_receive_event"
});
return false;
} else {
var self = this;
var temp_list = this.data.data_list;
if (temp_list[index]['is_operable'] != 0) {
tt.showLoading({ title: "处理中..." });
tt.request({
url: app.get_request_url("receive", "coupon"),
method: "POST",
data: { "coupon_id": value },
dataType: "json",
header: { 'content-type': 'application/x-www-form-urlencoded' },
success: res => {
tt.hideLoading();
if (res.data.code == 0) {
app.showToast(res.data.msg, "success");
if (self.data.data_base != null && self.data.data_base.is_repeat_receive != 1)
{
temp_list[index]['is_operable'] = 0;
temp_list[index]['is_operable_name'] = '已领取';
self.setData({ data_list: temp_list });
}
} else {
if (app.is_login_check(res.data, self, 'coupon_receive_event')) {
app.showToast(res.data.msg);
}
}
} else {
app.showToast(res.data.msg);
},
fail: () => {
tt.hideLoading();
app.showToast("服务器请求出错");
}
},
fail: () => {
tt.hideLoading();
app.showToast("服务器请求出错");
}
});
});
}
}
}
},
......
const app = getApp();
Page({
data: {
data_list_loding_status: 1,
data_bottom_line_status: false,
data_list: [],
params: null,
is_default: 0,
},
onLoad(params) {
this.setData({ params: params });
},
onShow() {
tt.setNavigationBarTitle({ title: app.data.common_pages_title.extraction_address });
this.init();
},
// 初始化
init() {
var user = app.get_user_info(this, "init");
if (user != false) {
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=init"
});
return false;
} else {
// 获取数据
this.get_data_list();
}
} else {
this.setData({
data_list_loding_status: 0,
data_bottom_line_status: false,
});
}
},
// 获取数据列表
get_data_list() {
// 加载loding
tt.showLoading({ title: "加载中..." });
this.setData({
data_list_loding_status: 1
});
// 获取数据
tt.request({
url: app.get_request_url("extraction", "useraddress"),
method: "POST",
data: {},
dataType: "json",
success: res => {
tt.hideLoading();
tt.stopPullDownRefresh();
if (res.data.code == 0) {
if (res.data.data.length > 0) {
// 获取当前默认地址
var is_default = 0;
for (var i in res.data.data) {
if (res.data.data[i]['is_default'] == 1) {
is_default = res.data.data[i]['id'];
}
}
// 设置数据
this.setData({
data_list: res.data.data,
is_default: is_default,
data_list_loding_status: 3,
data_bottom_line_status: true,
});
} else {
this.setData({
data_list_loding_status: 0
});
}
} else {
this.setData({
data_list_loding_status: 0
});
if (app.is_login_check(res.data, this, 'get_data_list')) {
app.showToast(res.data.msg);
}
}
},
fail: () => {
tt.hideLoading();
tt.stopPullDownRefresh();
this.setData({
data_list_loding_status: 2
});
app.showToast("服务器请求出错");
}
});
},
// 下拉刷新
onPullDownRefresh() {
this.get_data_list();
},
// 地图查看
address_map_event(e) {
app.location_authorize(this, 'address_map_handle', e);
},
// 地图查看处理
address_map_handle(e) {
var index = e.currentTarget.dataset.index || 0;
var ads = this.data.data_list[index] || null;
if (ads == null)
{
app.showToast("地址有误");
return false;
}
var lng = parseFloat(ads.lng || 0);
var lat = parseFloat(ads.lat || 0);
if (lng <= 0 || lat <= 0) {
app.showToast("坐标有误");
return false;
}
tt.openLocation({
latitude: lat,
longitude: lng,
scale: 18,
name: ads.alias || '',
address: (ads.province_name || '') + (ads.city_name || '') + (ads.county_name || '') + (ads.address || ''),
});
},
// 地址内容事件
address_conent_event(e) {
var index = e.currentTarget.dataset.index || 0;
var is_back = this.data.params.is_back || 0;
if (is_back == 1) {
tt.setStorage({
key: app.data.cache_buy_user_address_select_key,
data: this.data.data_list[index]
});
tt.navigateBack();
}
},
});
{
"enablePullDownRefresh": true
}
\ No newline at end of file
<view class="page">
<view tt:if="{{data_list.length > 0}}">
<view class="item bg-white spacing-mb" tt:for="{{data_list}}" tt:key="key">
<view bindtap="address_conent_event" data-index="{{index}}">
<view class="base oh">
<text tt:if="{{(item.alias || null) != null}}" class="address-alias">{{item.alias}}</text>
<text>{{item.name}}</text>
<text class="fr">{{item.tel}}</text>
</view>
<view class="address oh">
<image class="item-icon fl" src="/images/user-address.png" mode="widthFix" />
<view class="text fr">{{item.province_name}}{{item.city_name}}{{item.county_name}}{{item.address}}</view>
</view>
</view>
<view class="operation br-t oh">
<button tt:if="{{item.lng > 0 && item.lat > 0}}" class="fr cr-666 map-submit br" type="default" size="mini" bindtap="address_map_event" data-index="{{index}}" hover-class="none">查看地图</button>
</view>
</view>
</view>
<view tt:if="{{data_list.length == 0}}">
<import src="/pages/common/nodata.ttml" />
<template is="nodata" data="{{status: data_list_loding_status}}"></template>
</view>
<import src="/pages/common/bottom_line.ttml" />
<template is="bottom_line" data="{{status: data_bottom_line_status}}"></template>
</view>
\ No newline at end of file
.item {
padding: 10rpx 10rpx 0 10rpx;
}
.base, .address, .operation {
padding: 20rpx 0;
}
.address .item-icon {
width: 30rpx;
height: 35rpx !important;
}
.address-alias {
border: 1px solid #d2364c;
color: #d2364c;
padding: 2rpx 10rpx;
border-radius: 6rpx;
margin-right: 10rpx;
}
.address .text {
line-height: 44rpx;
width: calc(100% - 40rpx);
}
.operation .map-submit {
margin-left: 20rpx;
}
\ No newline at end of file
......@@ -34,6 +34,8 @@ Page({
goods_video_is_autoplay: false,
common_app_is_use_mobile_detail: 1,
common_app_is_online_service: 0,
// 限时秒杀插件
common_app_is_limitedtimediscount: 0,
plugins_limitedtimediscount_data: null,
......@@ -42,6 +44,21 @@ Page({
plugins_limitedtimediscount_timer: null,
plugins_limitedtimediscount_timers: null,
// 好物圈分享信息
common_app_is_good_thing : 0,
share_product: {
"item_code": "",
"title": "",
"desc": "",
"category_list": [],
"image_list": [],
"src_mini_program_path": "",
"brand_info": {},
},
// 海报分享
common_app_is_poster_share: 0,
// 优惠劵
plugins_coupon_data: null,
......@@ -51,6 +68,10 @@ Page({
// 站点模式
common_site_type: 0,
customer_service_tel: null,
// 优惠劵领取
temp_coupon_receive_index: null,
temp_coupon_receive_value: null,
},
onLoad(params) {
......@@ -123,10 +144,21 @@ Page({
show_field_price_text: (data.goods.show_field_price_text == '销售价') ? null : (data.goods.show_field_price_text.replace(/<[^>]+>/g, "") || null),
common_app_is_use_mobile_detail: data.common_app_is_use_mobile_detail || 0,
//common_app_is_online_service: data.common_app_is_online_service || 0,
common_app_is_limitedtimediscount: data.common_app_is_limitedtimediscount || 0,
plugins_limitedtimediscount_data: data.plugins_limitedtimediscount_data || null,
common_app_is_good_thing: data.common_app_is_good_thing || 0,
'share_product.item_code': data.goods.id.toString(),
'share_product.title': data.goods.title,
'share_product.image_list': data.goods.photo.map(function (v) { return v.images;}),
'share_product.desc': data.goods.simple_desc,
'share_product.category_list': data.goods.category_names || [],
'share_product.src_mini_program_path': '/pages/goods-detail/goods-detail?goods_id='+data.goods.id,
'share_product.brand_info.name': data.goods.brand_name,
common_app_is_poster_share: data.common_app_is_poster_share || 0,
plugins_coupon_data: data.plugins_coupon_data || null,
quick_nav_cart_count: data.common_cart_total || 0,
});
......@@ -259,76 +291,84 @@ Page({
// 收藏事件
goods_favor_event(e)
{
var user = app.get_user_cache_info(this, 'goods_favor_event');
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.navigateTo({
url: "/pages/login/login?event_callback=init"
});
return false;
} else {
tt.showLoading({title: '处理中...'});
var user = app.get_user_info(this, 'goods_favor_event');
if (user != false) {
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.navigateTo({
url: "/pages/login/login?event_callback=goods_favor_event"
});
return false;
} else {
tt.showLoading({title: '处理中...'});
tt.request({
url: app.get_request_url('favor', 'goods'),
method: 'POST',
data: {"id": this.data.goods.id},
dataType: 'json',
success: (res) => {
tt.hideLoading();
if(res.data.code == 0)
{
this.setData({
'goods.is_favor': res.data.data.status,
goods_favor_text: res.data.data.text,
goods_favor_icon: '/images/goods-detail-favor-icon-'+res.data.data.status+'.png'
});
app.showToast(res.data.msg, "success");
} else {
app.showToast(res.data.msg);
}
},
fail: () => {
tt.hideLoading();
tt.request({
url: app.get_request_url('favor', 'goods'),
method: 'POST',
data: {"id": this.data.goods.id},
dataType: 'json',
success: (res) => {
tt.hideLoading();
if(res.data.code == 0)
{
this.setData({
'goods.is_favor': res.data.data.status,
goods_favor_text: res.data.data.text,
goods_favor_icon: '/images/goods-detail-favor-icon-'+res.data.data.status+'.png'
});
app.showToast(res.data.msg, "success");
} else {
if (app.is_login_check(res.data, this, 'goods_favor_event')) {
app.showToast(res.data.msg);
}
}
},
fail: () => {
tt.hideLoading();
app.showToast('服务器请求出错');
}
});
app.showToast('服务器请求出错');
}
});
}
}
},
// 加入购物车事件
goods_cart_event(e, spec) {
var user = app.get_user_cache_info(this, 'goods_buy_confirm_event');
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.navigateTo({
url: "/pages/login/login?event_callback=init"
});
return false;
} else {
tt.showLoading({title: '处理中...' });
tt.request({
url: app.get_request_url('save', 'cart'),
method: 'POST',
data: { "goods_id": this.data.goods.id, "stock": this.data.temp_buy_number, "spec": JSON.stringify(spec) },
dataType: 'json',
success: (res) => {
tt.hideLoading();
if (res.data.code == 0) {
this.setData({ quick_nav_cart_count: res.data.data});
this.popup_close_event();
app.showToast(res.data.msg, "success");
} else {
app.showToast(res.data.msg);
}
},
fail: () => {
tt.hideLoading();
goods_cart_event(spec) {
var user = app.get_user_info(this, 'goods_buy_confirm_event');
if (user != false) {
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.navigateTo({
url: "/pages/login/login?event_callback=goods_buy_confirm_event"
});
return false;
} else {
tt.showLoading({title: '处理中...' });
tt.request({
url: app.get_request_url('save', 'cart'),
method: 'POST',
data: { "goods_id": this.data.goods.id, "stock": this.data.temp_buy_number, "spec": JSON.stringify(spec) },
dataType: 'json',
success: (res) => {
tt.hideLoading();
if (res.data.code == 0) {
this.setData({ quick_nav_cart_count: res.data.data});
this.popup_close_event();
app.showToast(res.data.msg, "success");
} else {
if (app.is_login_check(res.data, this, 'goods_buy_confirm_event')) {
app.showToast(res.data.msg);
}
}
},
fail: () => {
tt.hideLoading();
app.showToast('服务器请求出错');
}
});
app.showToast('服务器请求出错');
}
});
}
}
},
......@@ -560,61 +600,63 @@ Page({
// 确认
goods_buy_confirm_event(e) {
var user = app.get_user_cache_info(this, 'goods_buy_confirm_event');
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.navigateTo({
url: "/pages/login/login?event_callback=init"
});
return false;
} else {
// 属性
var temp_data = this.data.goods_specifications_choose;
var sku_count = temp_data.length;
var active_count = 0;
var spec = [];
if(sku_count > 0)
{
for(var i in temp_data)
var user = app.get_user_info(this, 'goods_buy_confirm_event');
if (user != false) {
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.navigateTo({
url: "/pages/login/login?event_callback=goods_buy_confirm_event"
});
return false;
} else {
// 属性
var temp_data = this.data.goods_specifications_choose;
var sku_count = temp_data.length;
var active_count = 0;
var spec = [];
if(sku_count > 0)
{
for(var k in temp_data[i]['value'])
for(var i in temp_data)
{
if((temp_data[i]['value'][k]['is_active'] || null) != null)
for(var k in temp_data[i]['value'])
{
active_count++;
spec.push({"type": temp_data[i]['name'], "value": temp_data[i]['value'][k]['name']});
if((temp_data[i]['value'][k]['is_active'] || null) != null)
{
active_count++;
spec.push({"type": temp_data[i]['name'], "value": temp_data[i]['value'][k]['name']});
}
}
}
if(active_count < sku_count)
{
app.showToast('请选择属性');
return false;
}
}
if(active_count < sku_count)
{
app.showToast('请选择属性');
return false;
}
}
// 操作类型
switch (this.data.buy_event_type) {
case 'buy' :
// 进入订单确认页面
var data = {
"buy_type": "goods",
"goods_id": this.data.goods.id,
"stock": this.data.temp_buy_number,
"spec": JSON.stringify(spec)
};
tt.navigateTo({
url: '/pages/buy/buy?data=' + JSON.stringify(data)
});
this.popup_close_event();
break;
// 操作类型
switch (this.data.buy_event_type) {
case 'buy' :
// 进入订单确认页面
var data = {
"buy_type": "goods",
"goods_id": this.data.goods.id,
"stock": this.data.temp_buy_number,
"spec": JSON.stringify(spec)
};
tt.navigateTo({
url: '/pages/buy/buy?data=' + JSON.stringify(data)
});
this.popup_close_event();
break;
case 'cart' :
this.goods_cart_event(e, spec);
break;
case 'cart' :
this.goods_cart_event(spec);
break;
default :
app.showToast("操作事件类型有误");
default :
app.showToast("操作事件类型有误");
}
}
}
},
......@@ -734,72 +776,32 @@ Page({
// 商品海报分享
poster_event() {
var user = app.get_user_cache_info(this, 'poster_event');
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.navigateTo({
url: "/pages/login/login?event_callback=init"
});
return false;
} else {
tt.showLoading({ title: '生成中...' });
tt.request({
url: app.get_request_url('poster', 'goods'),
method: 'POST',
data: { "goods_id": this.data.goods.id },
dataType: 'json',
success: (res) => {
tt.hideLoading();
if (res.data.code == 0) {
tt.previewImage({
current: res.data.data,
urls: [res.data.data]
});
} else {
app.showToast(res.data.msg);
}
},
fail: () => {
tt.hideLoading();
app.showToast("服务器请求出错");
}
});
}
},
// 优惠劵领取事件
coupon_receive_event(e) {
var user = app.get_user_cache_info(this, "coupon_receive_event");
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=coupon_receive_event"
});
return false;
} else {
var self = this;
var index = e.currentTarget.dataset.index;
var value = e.currentTarget.dataset.value;
var temp_list = this.data.plugins_coupon_data.data;
if (temp_list[index]['is_operable'] != 0) {
tt.showLoading({ title: "处理中..." });
var user = app.get_user_info(this, 'poster_event');
if (user != false) {
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.navigateTo({
url: "/pages/login/login?event_callback=poster_event"
});
return false;
} else {
tt.showLoading({ title: '生成中...' });
tt.request({
url: app.get_request_url("receive", "coupon"),
method: "POST",
data: { "coupon_id": value },
dataType: "json",
header: { 'content-type': 'application/x-www-form-urlencoded' },
success: res => {
url: app.get_request_url('poster', 'goods'),
method: 'POST',
data: { "goods_id": this.data.goods.id },
dataType: 'json',
success: (res) => {
tt.hideLoading();
if (res.data.code == 0) {
app.showToast(res.data.msg, "success");
if (self.data.plugins_coupon_data.base != null && self.data.plugins_coupon_data.base.is_repeat_receive != 1) {
temp_list[index]['is_operable'] = 0;
temp_list[index]['is_operable_name'] = '已领取';
self.setData({ 'plugins_coupon_data.data': temp_list });
}
tt.previewImage({
current: res.data.data,
urls: [res.data.data]
});
} else {
app.showToast(res.data.msg);
if (app.is_login_check(res.data, this, 'poster_event')) {
app.showToast(res.data.msg);
}
}
},
fail: () => {
......@@ -811,6 +813,64 @@ Page({
}
},
// 优惠劵领取事件
coupon_receive_event(e) {
// 参数处理
if((e || null) == null)
{
var index = this.data.temp_coupon_receive_index;
var value = this.data.temp_coupon_receive_value;
} else {
var index = e.currentTarget.dataset.index;
var value = e.currentTarget.dataset.value;
this.setData({temp_coupon_receive_index: index, temp_coupon_receive_value: value});
}
// 登录校验
var user = app.get_user_info(this, 'coupon_receive_event');
if (user != false) {
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.navigateTo({
url: "/pages/login/login?event_callback=coupon_receive_event"
});
return false;
} else {
var self = this;
var temp_list = this.data.plugins_coupon_data.data;
if (temp_list[index]['is_operable'] != 0) {
tt.showLoading({ title: "处理中..." });
tt.request({
url: app.get_request_url("receive", "coupon"),
method: "POST",
data: { "coupon_id": value },
dataType: "json",
header: { 'content-type': 'application/x-www-form-urlencoded' },
success: res => {
tt.hideLoading();
if (res.data.code == 0) {
app.showToast(res.data.msg, "success");
if (self.data.plugins_coupon_data.base != null && self.data.plugins_coupon_data.base.is_repeat_receive != 1) {
temp_list[index]['is_operable'] = 0;
temp_list[index]['is_operable_name'] = '已领取';
self.setData({ 'plugins_coupon_data.data': temp_list });
}
} else {
if (app.is_login_check(res.data, self, 'coupon_receive_event')) {
app.showToast(res.data.msg);
}
}
},
fail: () => {
tt.hideLoading();
app.showToast("服务器请求出错");
}
});
}
}
}
},
// 展示型事件
exhibition_submit_event(e) {
app.call_tel(this.data.customer_service_tel);
......@@ -818,7 +878,7 @@ Page({
// 自定义分享
onShareAppMessage() {
var user = app.get_user_cache_info(this, 'goods_favor_event') || null;
var user = app.get_user_cache_info() || null;
var user_id = (user != null && (user.id || null) != null) ? user.id : 0;
return {
title: app.data.application_title +'-'+ this.data.goods.title,
......@@ -826,5 +886,4 @@ Page({
path: '/pages/goods-detail/goods-detail?goods_id=' + this.data.goods.id +'&referrer='+user_id
};
},
});
......@@ -132,13 +132,13 @@
<text class="dis-block cr-888">{{goods_favor_text}}</text>
</view>
<view class="fr {{common_site_type == 1 ? 'exhibition-mode' : ''}}">
<!-- 展示型 -->
<!-- 站点模式 1 展示型 -->
<block tt:if="{{common_site_type == 1}}">
<button class="bg-main fl" type="default" bindtap="exhibition_submit_event" hover-class="none">{{nav_submit_text}}</button>
</block>
<!-- 销售型,自提点,虚拟销售 -->
<block tt:else>
<block wx:else>
<button class="bg-warning fl" type="default" bindtap="cart_submit_event" hover-class="none" disabled="{{nav_submit_is_disabled}}">加入购物车</button>
<button class="bg-main fl" type="default" bindtap="buy_submit_event" hover-class="none" disabled="{{nav_submit_is_disabled}}">{{nav_submit_text}}</button>
</block>
......
......@@ -179,7 +179,6 @@
}
.goods-base button {
background: #fff;
padding: 0;
}
.goods-base .goods-share {
position: absolute;
......
......@@ -33,6 +33,13 @@ Page({
* 登录授权事件
*/
get_user_info_event(e) {
this.user_auth_code();
},
/**
* 用户授权
*/
user_auth_code() {
var self = this;
tt.getSetting({
success(res) {
......
......@@ -14,16 +14,23 @@ Page({
},
init() {
var user = app.get_user_cache_info(this, "init");
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=init"
});
return false;
var user = app.get_user_info(this, "init");
if (user != false) {
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=init"
});
return false;
} else {
// 获取数据
this.get_data_list();
}
} else {
// 获取数据
this.get_data_list();
this.setData({
data_list_loding_status: 0,
data_bottom_line_status: false,
});
}
},
......@@ -91,8 +98,9 @@ Page({
this.setData({
data_list_loding_status: 0
});
app.showToast(res.data.msg);
if (app.is_login_check(res.data, this, 'get_data_list')) {
app.showToast(res.data.msg);
}
}
},
fail: () => {
......
......@@ -37,22 +37,33 @@ Page({
},
init() {
var user = app.get_user_cache_info(this, "init");
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=init"
});
return false;
} else {
// 获取地址数据
if((this.data.params.id || null) != null)
{
this.get_user_address();
}
var user = app.get_user_info(this, "init");
if (user != false) {
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=init"
});
this.setData({
data_list_loding_status: 2,
data_list_loding_msg: '请先绑定手机号码',
});
return false;
} else {
// 获取地址数据
if((this.data.params.id || null) != null)
{
this.get_user_address();
}
// 获取省
this.get_province_list();
// 获取省
this.get_province_list();
}
} else {
this.setData({
data_list_loding_status: 2,
data_list_loding_msg: '请先授权用户信息',
});
}
},
......@@ -89,7 +100,9 @@ Page({
self.init_value();
}, 500);
} else {
app.showToast(res.data.msg);
if (app.is_login_check(res.data)) {
app.showToast(res.data.msg);
}
}
},
fail: () => {
......@@ -289,7 +302,11 @@ Page({
tt.navigateBack();
}, 1000);
} else {
app.showToast(res.data.msg);
if (app.is_login_check(res.data)) {
app.showToast(res.data.msg);
} else {
app.showToast('提交失败,请重试!');
}
}
},
fail: () => {
......
......@@ -19,16 +19,23 @@ Page({
// 初始化
init() {
var user = app.get_user_cache_info(this, "init");
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=init"
});
return false;
var user = app.get_user_info(this, "init");
if (user != false) {
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=init"
});
return false;
} else {
// 获取数据
this.get_data_list();
}
} else {
// 获取数据
this.get_data_list();
this.setData({
data_list_loding_status: 0,
data_bottom_line_status: false,
});
}
},
......@@ -77,8 +84,9 @@ Page({
this.setData({
data_list_loding_status: 0
});
app.showToast(res.data.msg);
if (app.is_login_check(res.data, this, 'get_data_list')) {
app.showToast(res.data.msg);
}
}
},
fail: () => {
......@@ -149,7 +157,11 @@ Page({
}
} else {
app.showToast(res.data.msg);
if (app.is_login_check(res.data)) {
app.showToast(res.data.msg);
} else {
app.showToast('提交失败,请重试!');
}
}
},
fail: () => {
......@@ -196,7 +208,11 @@ Page({
app.showToast(res.data.msg, "success");
} else {
app.showToast(res.data.msg);
if (app.is_login_check(res.data)) {
app.showToast(res.data.msg);
} else {
app.showToast('提交失败,请重试!');
}
}
},
fail: () => {
......
......@@ -3,6 +3,7 @@
<view class="item bg-white spacing-mb" tt:for="{{data_list}}" tt:key="key">
<view bindtap="address_conent_event" data-index="{{index}}">
<view class="base oh">
<text tt:if="{{(item.alias || null) != null}}" class="address-alias">{{item.alias}}</text>
<text>{{item.name}}</text>
<text class="fr">{{item.tel}}</text>
</view>
......
......@@ -5,9 +5,16 @@
padding: 20rpx 0;
}
.address .item-icon {
width: 35rpx;
width: 30rpx;
height: 35rpx !important;
}
.address-alias {
border: 1px solid #d2364c;
color: #d2364c;
padding: 2rpx 10rpx;
border-radius: 6rpx;
margin-right: 10rpx;
}
.address .text {
line-height: 44rpx;
width: calc(100% - 40rpx);
......
......@@ -16,16 +16,23 @@ Page({
},
init() {
var user = app.get_user_cache_info(this, "init");
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=init"
});
return false;
var user = app.get_user_info(this, "init");
if (user != false) {
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=init"
});
return false;
} else {
// 获取数据
this.get_data_list();
}
} else {
// 获取数据
this.get_data_list();
this.setData({
data_list_loding_status: 0,
data_bottom_line_status: false,
});
}
},
......@@ -91,8 +98,9 @@ Page({
this.setData({
data_list_loding_status: 0
});
app.showToast(res.data.msg);
if (app.is_login_check(res.data, this, 'get_data_list')) {
app.showToast(res.data.msg);
}
}
},
fail: () => {
......
......@@ -23,16 +23,23 @@ Page({
},
init() {
var user = app.get_user_cache_info(this, "init");
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=init"
});
return false;
var user = app.get_user_info(this, "init");
if (user != false) {
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=init"
});
return false;
} else {
// 获取数据
this.get_data_list();
}
} else {
// 获取数据
this.get_data_list();
this.setData({
data_list_loding_status: 0,
data_bottom_line_status: false,
});
}
},
......@@ -66,7 +73,9 @@ Page({
data_list_loding_status: 2,
data_list_loding_msg: res.data.msg,
});
app.showToast(res.data.msg);
if (app.is_login_check(res.data, self, 'get_data_list')) {
app.showToast(res.data.msg);
}
}
},
fail: () => {
......
......@@ -14,16 +14,23 @@ Page({
},
init() {
var user = app.get_user_cache_info(this, "init");
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=init"
});
return false;
var user = app.get_user_info(this, "init");
if (user != false) {
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=init"
});
return false;
} else {
// 获取数据
this.get_data_list();
}
} else {
// 获取数据
this.get_data_list();
this.setData({
data_list_loding_status: 0,
data_bottom_line_status: false,
});
}
},
......@@ -89,8 +96,9 @@ Page({
this.setData({
data_list_loding_status: 0
});
app.showToast(res.data.msg);
if (app.is_login_check(res.data, this, 'get_data_list')) {
app.showToast(res.data.msg);
}
}
},
fail: () => {
......@@ -156,7 +164,11 @@ Page({
app.showToast(res.data.msg, "success");
} else {
app.showToast(res.data.msg);
if (app.is_login_check(res.data)) {
app.showToast(res.data.msg);
} else {
app.showToast('提交失败,请重试!');
}
}
},
fail: () => {
......
......@@ -14,16 +14,23 @@ Page({
},
init() {
var user = app.get_user_cache_info(this, "init");
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=init"
});
return false;
var user = app.get_user_info(this, "init");
if (user != false) {
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=init"
});
return false;
} else {
// 获取数据
this.get_data_list();
}
} else {
// 获取数据
this.get_data_list();
this.setData({
data_list_loding_status: 0,
data_bottom_line_status: false,
});
}
},
......@@ -88,8 +95,9 @@ Page({
this.setData({
data_list_loding_status: 0
});
app.showToast(res.data.msg);
if (app.is_login_check(res.data, this, 'get_data_list')) {
app.showToast(res.data.msg);
}
}
},
fail: () => {
......@@ -154,7 +162,11 @@ Page({
app.showToast(res.data.msg, "success");
} else {
app.showToast(res.data.msg);
if (app.is_login_check(res.data)) {
app.showToast(res.data.msg);
} else {
app.showToast('提交失败,请重试!');
}
}
},
fail: () => {
......
......@@ -14,16 +14,23 @@ Page({
},
init() {
var user = app.get_user_cache_info(this, "init");
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=init"
});
return false;
var user = app.get_user_info(this, "init");
if (user != false) {
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=init"
});
return false;
} else {
// 获取数据
this.get_data_list();
}
} else {
// 获取数据
this.get_data_list();
this.setData({
data_list_loding_status: 0,
data_bottom_line_status: false,
});
}
},
......@@ -91,8 +98,9 @@ Page({
this.setData({
data_list_loding_status: 0
});
app.showToast(res.data.msg);
if (app.is_login_check(res.data, this, 'get_data_list')) {
app.showToast(res.data.msg);
}
}
},
fail: () => {
......
......@@ -9,9 +9,11 @@ Page({
detail: null,
detail_list: [],
extension_data: [],
site_fictitious: null,
},
onLoad(params) {
//params['id'] = 5;
this.setData({params: params});
this.init();
},
......@@ -40,29 +42,31 @@ Page({
if (res.data.code == 0) {
var data = res.data.data;
self.setData({
detail: data,
detail: data.data,
detail_list:[
{name: "订单号", value: data.order_no || ''},
{name: "状态", value: data.status_name || ''},
{name: "支付状态", value: data.pay_status_name || ''},
{name: "单价", value: data.price || ''},
{name: "总价", value: data.total_price || ''},
{name: "优惠金额", value: data.preferential_price || ''},
{name: "增加金额", value: data.increase_price || '' },
{name: "支付金额", value: data.pay_price || ''},
{name: "支付方式", value: data.payment_name || ''},
{name: "快递公司", value: data.express_name || ''},
{name: "快递单号", value: data.express_number || ''},
{name: "用户留言", value: data.user_note || ''},
{name: "创建时间", value: data.add_time || ''},
{name: "确认时间", value: data.confirm_time || ''},
{name: "支付时间", value: data.pay_time || ''},
{name: "发货时间", value: data.delivery_time || ''},
{name: "收货时间", value: data.collect_time || ''},
{name: "取消时间", value: data.close_time || ''},
{name: "关闭时间", value: data.close_time || ''},
{name: "订单号", value: data.data.order_no || ''},
{name: "订单模式", value: data.data.order_model_name || '' },
{name: "状态", value: data.data.status_name || ''},
{name: "支付状态", value: data.data.pay_status_name || ''},
{name: "单价", value: data.data.price || ''},
{name: "总价", value: data.data.total_price || ''},
{name: "优惠金额", value: data.data.preferential_price || ''},
{name: "增加金额", value: data.data.increase_price || '' },
{name: "支付金额", value: data.data.pay_price || ''},
{name: "支付方式", value: data.data.payment_name || ''},
{name: "快递公司", value: data.data.express_name || ''},
{name: "快递单号", value: data.data.express_number || ''},
{name: "用户留言", value: data.data.user_note || ''},
{name: "创建时间", value: data.data.add_time || ''},
{name: "确认时间", value: data.data.confirm_time || ''},
{name: "支付时间", value: data.data.pay_time || ''},
{name: "发货时间", value: data.data.delivery_time || ''},
{name: "收货时间", value: data.data.collect_time || ''},
{name: "取消时间", value: data.data.close_time || ''},
{name: "关闭时间", value: data.data.close_time || ''},
],
extension_data: data.extension_data || [],
extension_data: data.data.extension_data || [],
site_fictitious: data.site_fictitious || null,
data_list_loding_status: 3,
data_bottom_line_status: true,
data_list_loding_msg: '',
......@@ -73,7 +77,9 @@ Page({
data_bottom_line_status: false,
data_list_loding_msg: res.data.msg,
});
app.showToast(res.data.msg);
if (app.is_login_check(res.data, self, 'init')) {
app.showToast(res.data.msg);
}
}
},
fail: () => {
......@@ -90,6 +96,36 @@ Page({
});
},
// 地图查看
address_map_event(e) {
app.location_authorize(this, 'address_map_handle', e);
},
// 地图查看处理
address_map_handle(e) {
if ((this.data.detail.address_data || null) == null)
{
app.showToast("地址有误");
return false;
}
var ads = this.data.detail.address_data;
var lng = parseFloat(ads.lng || 0);
var lat = parseFloat(ads.lat || 0);
if (lng <= 0 || lat <= 0) {
app.showToast("坐标有误");
return false;
}
tt.openLocation({
latitude: lat,
longitude: lng,
scale: 18,
name: ads.alias || '',
address: (ads.province_name || '') + (ads.city_name || '') + (ads.county_name || '') + (ads.address || ''),
});
},
// 下拉刷新
onPullDownRefresh() {
this.init();
......
<view tt:if="{{detail != null}}">
<view class="address bg-white spacing-mb">
<!-- 地址 -->
<view tt:if="{{detail.order_model == 0 || detail.order_model == 2}}" class="address bg-white spacing-mb">
<view class="address-base oh">
<text>{{detail.receive_name}}</text>
<text class="fr">{{detail.receive_tel}}</text>
<text tt:if="{{(detail.address_data.alias || null) != null}}" class="address-alias">{{detail.address_data.alias}}</text>
<text>{{detail.address_data.name}}</text>
<text class="fr">{{detail.address_data.tel}}</text>
</view>
<view class="address-detail oh">
<image class="icon fl" src="/images/user-address.png" mode="widthFix" />
<view class="text fr">{{detail.receive_province_name}}{{detail.receive_city_name}}{{detail.receive_county_name}}{{detail.receive_address}}</view>
<view class="text fr">
{{detail.address_data.province_name}}{{detail.address_data.city_name}}{{detail.address_data.county_name}}{{detail.address_data.address}}
<text tt:if="{{detail.order_model == 2 && (detail.address_data.lng || 0) > 0 && (detail.address_data.lat || 0) > 0}}" class="cr-666 br address-map-submit" bindtap="address_map_event">查看位置</text>
</view>
</view>
</view>
<!-- 商品列表 -->
<view class="goods bg-white spacing-mb">
<view tt:for="{{detail.items}}" tt:key="item" class="goods-item oh">
<view tt:for="{{detail.items}}" tt:key="item" class="goods-item br-b-dashed oh">
<navigator url="/pages/goods-detail/goods-detail?goods_id={{item.goods_id}}" hover-class="none">
<image class="goods-image fl" src="{{item.images}}" mode="aspectFill" />
<view class="goods-base">
......@@ -29,22 +35,60 @@
</view>
</navigator>
</view>
<view class="order-describe">{{detail.describe}}</view>
</view>
<!-- 虚拟销售数据 -->
<view tt:if="{{detail.order_model == 3 && detail.pay_status == 1 && (detail.status == 3 || detail.status == 4)}}" class="panel-item spacing-mt site-fictitious">
<view class="panel-title">{{site_fictitious.title || '密钥信息'}}</view>
<view class="panel-content bg-white oh">
<view tt:if="{{(site_fictitious.tips || null) != null}}" class="tips-value">
<rich-text nodes="{{site_fictitious.tips}}"></rich-text>
</view>
<view tt:for="{{detail.items}}" tt:key="item" class="item br-b-dashed oh">
<image class="left-image br fl" src="{{item.images}}" mode="aspectFill" />
<view class="right-value fr">
<view tt:if="{{(item.fictitious_goods_value || null) != null}}" class="rich-text-value">
<rich-text nodes="{{item.fictitious_goods_value}}"></rich-text>
</view>
<text tt:else class="cr-888 not-value">未配置数据</text>
</view>
</view>
</view>
</view>
<!-- 自提信息 -->
<view tt:if="{{detail.order_model == 2 && (detail.status == 2 || detail.status == 3) && (detail.extraction_data || null) != null}}" class="panel-item spacing-mt site-extraction">
<view class="panel-title">取货信息</view>
<view class="panel-content bg-white oh">
<view>
<text>取货码:</text>
<text class="code">{{detail.extraction_data.code || '取货码不存在、请联系管理员'}}</text>
</view>
<image tt:if="{{(detail.extraction_data.images || null) != null}}" class="br qrcode" src="{{detail.extraction_data.images}}" mode="aspectFill" />
</view>
</view>
<!-- 订单基础数据 -->
<view tt:if="{{detail_list.length > 0}}" class="detail-list bg-white">
<view tt:for="{{detail_list}}" tt:key="item" class="item br-b oh">
<view class="title fl">{{item.name}}</view>
<view class="content cr-888 fl br-l">{{item.value}}</view>
<view tt:if="{{detail_list.length > 0}}" class="panel-item spacing-mt">
<view class="panel-title">基础数据</view>
<view class="panel-content bg-white">
<view tt:for="{{detail_list}}" tt:key="item" class="item br-b oh">
<view class="title fl">{{item.name}}</view>
<view class="content cr-888 fl br-l">{{item.value}}</view>
</view>
</view>
</view>
<!-- 扩展数据 -->
<view tt:if="{{extension_data.length > 0}}" class="extension-list bg-white spacing-mt">
<view tt:for="{{extension_data}}" tt:key="item" class="item br-b oh">
<view tt:if="{{extension_data.length > 0}}" class="panel-item spacing-mt extension-list">
<view class="panel-title">扩展数据</view>
<view class="panel-content bg-white">
<view tt:for="{{extension_data}}" tt:key="item" class="item br-b oh">
<text class="title">{{item.name}}</text>
<text class="content cr-888 br-l">{{item.tips}}</text>
</view>
</view>
</view>
<import src="/pages/common/bottom_line.ttml" />
......
/*
* 地址信息
*/
.address {
padding: 10rpx;
}
......@@ -5,7 +8,7 @@
padding: 10rpx 35rpx 10rpx 10rpx;
}
.address-detail .icon {
width: 35rpx;
width: 30rpx;
height: 35rpx !important;
}
.address-detail .text {
......@@ -23,13 +26,23 @@
height: 85rpx;
line-height: 85rpx;
}
.address-alias {
border: 1px solid #d2364c;
color: #d2364c;
padding: 2rpx 10rpx;
border-radius: 6rpx;
margin-right: 10rpx;
}
/*
* 商品信息
*/
.goods-base {
min-height: 160rpx;
margin-left: 180rpx;
}
.goods .goods-item:not(:last-child) {
border-bottom: 1px dashed #efefef;
.goods .goods-item:last-child {
border-bottom: 0;
}
.goods-item {
padding: 20rpx 10rpx;
......@@ -50,26 +63,36 @@
right: 0;
bottom: 0;
}
.order-describe {
padding: 20rpx 10rpx;
}
/*
* 基础信息
* 面板信息
*/
.detail-list {
padding: 0 10rpx;
}
.detail-list .item {
.panel-item .panel-title {
background: #fff;
font-weight: bold;
padding: 15rpx;
border-bottom: 2px solid #eee;
font-size: 34rpx;
}
.panel-item .panel-content .item {
padding: 20rpx 0;
}
.detail-list .item .title {
.panel-item .panel-content .item:last-child {
border: 0;
}
.panel-item .panel-content .item .title {
width: 25%;
padding-left: 20rpx;
}
.detail-list .item .content {
.panel-item .panel-content .item .content {
width: calc(75% - 50rpx);
padding-left: 20rpx;
min-height: 46rpx;
}
.detail-list .item view {
.panel-item .panel-content .item view {
line-height: 46rpx;
}
......@@ -84,4 +107,62 @@
}
.extension-list .item .content {
padding-left: 20rpx;
}
/*
* 虚拟销售信息
*/
.site-fictitious .panel-content {
padding: 0 20rpx;
}
.site-fictitious .panel-content .tips-value {
color: #f37b1d;
background-color: #fff2e9;
border-color: #ffebdb;
padding: 10rpx;
margin-top: 20rpx;
}
.site-fictitious .panel-content .left-image {
width: 80rpx;
height: 80rpx;
}
.site-fictitious .panel-content .right-value,
.site-fictitious .panel-content .right-value .rich-text-value {
width: calc(100% - 100rpx);
}
.site-fictitious .panel-content .item {
position: relative;
}
.site-fictitious .panel-content .right-value .rich-text-value {
position: absolute;
top: 0;
right: 0;
}
.site-fictitious .panel-content .right-value .not-value {
margin-left: 10rpx;
}
/*
* 自提信息
*/
.site-extraction .panel-content {
padding: 20rpx;
}
.site-extraction .panel-content .code {
background: #5eb95e;
color: #fff;
}
.site-extraction .panel-content .code,
.address-map-submit {
padding: 1rpx 16rpx;
border-radius: 6rpx;
}
.site-extraction .panel-content .qrcode {
margin-top: 15rpx;
width: 300rpx;
height: 300rpx;
}
.address-map-submit {
margin-left: 20rpx;
background: #f5f5f5;
}
\ No newline at end of file
......@@ -49,16 +49,23 @@ Page({
},
init() {
var user = app.get_user_cache_info(this, "init");
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=init"
});
return false;
var user = app.get_user_info(this, 'init');
if (user != false) {
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=init"
});
return false;
} else {
// 获取数据
this.get_data_list();
}
} else {
// 获取数据
this.get_data_list();
this.setData({
data_list_loding_status: 0,
data_bottom_line_status: false,
});
}
},
......@@ -156,8 +163,9 @@ Page({
data_list_loding_status: 0,
load_status: 1,
});
app.showToast(res.data.msg);
if (app.is_login_check(res.data, this, 'get_data_list')) {
app.showToast(res.data.msg);
}
}
},
fail: () => {
......@@ -215,7 +223,7 @@ Page({
tt.showLoading({title: "请求中..." });
tt.request({
url: app.get_request_url("pay", "toutiao"),
url: app.get_request_url("pay", "order"),
method: "POST",
data: {
id: order_id,
......@@ -227,36 +235,29 @@ Page({
if (res.data.code == 0) {
// 是否在线支付,非在线支付则支付成功
if (res.data.data.is_online_pay == 0) {
var temp_data_list = this.data.data_list;
temp_data_list[index]['status'] = 2;
temp_data_list[index]['status_name'] = '待发货';
this.setData({ data_list: temp_data_list });
// 数据设置
self.order_item_pay_success_handle(index);
app.showToast("支付成功", "success");
} else {
tt.pay({
orderInfo: res.data.data.order_info,
service: res.data.data.service,
success(res) {
if (res.code == 0) {
// 数据设置
var temp_data_list = self.data.data_list;
temp_data_list[index]['status'] = 2;
temp_data_list[index]['status_name'] = '待发货';
self.setData({ data_list: temp_data_list });
// 跳转支付页面
wx.navigateTo({
url: "/pages/paytips/paytips?code=9000&total_price=" +
self.data.data_list[index]['total_price']
});
} else {
app.showToast('支付失败');
}
tt.requestPayment({
timeStamp: res.data.data.data.timeStamp,
nonceStr: res.data.data.data.nonceStr,
package: res.data.data.data.package,
signType: res.data.data.data.signType,
paySign: res.data.data.data.paySign,
success: function(res) {
// 数据设置
self.order_item_pay_success_handle(index);
// 跳转支付页面
tt.navigateTo({
url: "/pages/paytips/paytips?code=9000&total_price=" +
self.data.data_list[index]['total_price']
});
},
fail(res) {
console.log(res, 'pay-fail')
app.showToast('调起收银台失败-'+res.data.code);
fail: function (res) {
app.showToast('支付失败');
}
});
}
......@@ -271,6 +272,32 @@ Page({
});
},
// 支付成功数据设置
order_item_pay_success_handle(index) {
// 数据设置
var temp_data_list = this.data.data_list;
switch (parseInt(temp_data_list[index]['order_model'])) {
// 销售模式
case 0:
temp_data_list[index]['status'] = 2;
temp_data_list[index]['status_name'] = '待发货';
break;
// 自提模式
case 2:
temp_data_list[index]['status'] = 2;
temp_data_list[index]['status_name'] = '待取货';
break;
// 虚拟模式
case 3:
temp_data_list[index]['status'] = 3;
temp_data_list[index]['status_name'] = '待收货';
break;
}
this.setData({ data_list: temp_data_list });
},
// 取消
cancel_event(e) {
tt.showModal({
......
......@@ -14,7 +14,7 @@
<text class="cr-666">{{item.add_time}}</text>
<text class="fr cr-main">{{item.status_name}}</text>
</view>
<view tt:for="{{item.items}}" tt:key="key" tt:for-item="detail" class="goods-item oh">
<view tt:for="{{item.items}}" tt:key="key" tt:for-item="detail" class="goods-item br-b-dashed oh">
<navigator url="/pages/user-order-detail/user-order-detail?id={{item.id}}" hover-class="none">
<image class="goods-image fl" src="{{detail.images}}" mode="aspectFill" />
<view class="goods-base">
......@@ -34,10 +34,10 @@
</navigator>
</view>
<view class="item-describe tr cr-666">{{item.describe}}</view>
<view tt:if="{{item.status <= 3 || (item.status == 4 && item.user_is_comments == 0)}}" class="item-operation tr br-t">
<view tt:if="{{item.status == 1 || item.status == 3 || (item.status == 4 && item.user_is_comments == 0) || (item.status == 2 && item.order_model != 2)}}" class="item-operation tr br-t">
<button tt:if="{{item.status <= 1}}" class="submit-cancel" type="default" size="mini" bindtap="cancel_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">取消</button>
<button tt:if="{{item.status == 1}}" class="submit-pay cr-666 br" type="default" size="mini" bindtap="pay_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">支付</button>
<button tt:if="{{item.status == 2}}" class="submit-rush cr-666 br" type="default" size="mini" bindtap="rush_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">催催</button>
<button tt:if="{{item.status == 2 && item.order_model != 2}}" class="submit-rush cr-666 br" type="default" size="mini" bindtap="rush_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">催催</button>
<button tt:if="{{item.status == 3}}" class="submit-success cr-666 br" type="default" size="mini" bindtap="collect_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">收货</button>
<button tt:if="{{item.status == 4 && item.user_is_comments == 0}}" class="submit-success cr-666 br" type="default" size="mini" bindtap="comments_event" data-value="{{item.id}}" data-index="{{index}}" hover-class="none">评论</button>
</view>
......
......@@ -24,8 +24,8 @@
.goods-title {
line-height: 36rpx;
}
.list-item .goods-item:not(:last-child) {
border-bottom: 1px dashed #efefef;
.list-item .goods-item:last-child {
border-bottom: 0;
}
.goods-item {
padding: 20rpx 10rpx;
......
......@@ -51,16 +51,23 @@ Page({
},
init() {
var user = app.get_user_cache_info(this, "init");
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=init"
});
return false;
var user = app.get_user_info(this, "init");
if (user != false) {
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.redirectTo({
url: "/pages/login/login?event_callback=init"
});
return false;
} else {
// 获取数据
this.get_data_list();
}
} else {
// 获取数据
this.get_data_list();
this.setData({
data_list_loding_status: 0,
data_bottom_line_status: false,
});
}
},
......@@ -134,8 +141,9 @@ Page({
data_list_loding_status: 0,
data_list_loding_msg: res.data.msg,
});
app.showToast(res.data.msg);
if (app.is_login_check(res.data, this, 'get_data_list')) {
app.showToast(res.data.msg);
}
}
},
fail: () => {
......@@ -209,7 +217,11 @@ Page({
app.showToast(res.data.msg, "success");
} else {
app.showToast(res.data.msg);
if (app.is_login_check(res.data)) {
app.showToast(res.data.msg);
} else {
app.showToast('提交失败,请重试!');
}
}
},
fail: () => {
......
......@@ -32,31 +32,32 @@ Page({
},
init(e) {
var user = app.get_user_cache_info(this, "init"),
self = this;
// 用户未绑定用户则转到登录页面
var msg = (user == false) ? '授权用户信息' : '绑定手机号码';
if (app.user_is_need_login(user)) {
tt.showModal({
title: '温馨提示',
content: msg,
confirmText: '确认',
cancelText: '暂不',
success: (result) => {
tt.stopPullDownRefresh();
if(result.confirm) {
tt.navigateTo({
url: "/pages/login/login?event_callback=init"
var user = app.get_user_info(this, "init"),
self = this;
if (user != false) {
// 用户未绑定用户则转到登录页面
if (app.user_is_need_login(user)) {
tt.showModal({
title: '温馨提示',
content: '绑定手机号码',
confirmText: '确认',
cancelText: '暂不',
success: (result) => {
tt.stopPullDownRefresh();
if(result.confirm) {
tt.navigateTo({
url: "/pages/login/login?event_callback=init"
});
}
self.setData({
avatar: user.avatar || app.data.default_user_head_src,
nickname: user.user_name_view || '用户名',
});
}
self.setData({
avatar: user.avatar || app.data.default_user_head_src,
nickname: user.user_name_view || '用户名',
});
},
});
} else {
self.get_data();
},
});
} else {
self.get_data();
}
}
},
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册