|
|
|
|
|
import api from '../../../common/api.js';
|
|
|
// import {wexinPay} from '../../../utils/wxpay';
|
|
|
import { getYHStorageSync, getImageUrlWithWH} from '../../../utils/util';
|
|
|
import { getChannelCode, getGenderCode, getRecPosCode, getRecommandContentCode } from '../../../utils/home';
|
|
|
import { parseBrandListData } from '../../../utils/productListUtil';
|
|
|
// import {
|
|
|
// logEvent,
|
|
|
// YB_PAGE_OPEN_L,
|
|
|
// YB_SHARE_RESULT_L,
|
|
|
// } from '../../../libs/analytics.js'
|
|
|
// import {listen } from '../../../utils/login';
|
|
|
|
|
|
const APP_SPACEORDERS_DETAIL = "app.SpaceOrders.detail";
|
|
|
const APP_SPACEORDERS_CLOSE = "app.SpaceOrders.close";
|
|
|
const APP_SPACEORDERS_DELORDERBYCODE = "app.SpaceOrders.delOrderByCode";
|
|
|
const APP_SPACEORDERS_CONFIRM = "app.SpaceOrders.confirm";
|
|
|
|
|
|
let app = getApp();
|
|
|
const pixelRatio = app.globalData.systemInfo.pixelRatio;
|
|
|
const windowWidth = app.globalData.systemInfo.windowWidth;
|
|
|
const windowHeight = app.globalData.systemInfo.windowHeight;
|
|
|
const BANNER_RATIO = 324 / 750;
|
|
|
let bannerWidth = windowWidth;
|
|
|
let bannerHeight = bannerWidth * BANNER_RATIO;
|
|
|
let timer;
|
|
|
|
|
|
Page({
|
|
|
data: {
|
|
|
isShowExpress: false,
|
|
|
isLoading: true,
|
|
|
isShowHomeNav: false,
|
|
|
resources:[],
|
|
|
recommdData:[],
|
|
|
data:{},
|
|
|
bannerWidth,
|
|
|
bannerHeight,
|
|
|
requestOK: false,
|
|
|
order_code: "",
|
|
|
create_time: "",
|
|
|
from_page_name: '',
|
|
|
from_page_param: '',
|
|
|
current_page_name: 'orderDetail',
|
|
|
current_page_param: '',
|
|
|
tipimgsrc: '../images/tan-ic@2x.png',
|
|
|
arrowImg: '../images/arrow_right@2x.png',
|
|
|
refundReason: [],//退款理由
|
|
|
showReason:false,
|
|
|
reFaudCode:"",
|
|
|
reasonIndex:0,
|
|
|
pay_lefttime: 0,
|
|
|
time_left: '',
|
|
|
|
|
|
token: '',
|
|
|
activityBanner: '',
|
|
|
},
|
|
|
|
|
|
formSubmit: function (e) {
|
|
|
let formId = e.detail.formId;
|
|
|
let _self = this;
|
|
|
if (!app.getUid() || !formId || formId.length === 0) return;
|
|
|
//上报formId
|
|
|
let formIdParams = {
|
|
|
uid: app.getUid(),
|
|
|
order_code: _self.data.order_code,
|
|
|
openId: app.globalData.openID ? app.globalData.openID : getYHStorageSync('openID','orderDetail'),
|
|
|
miniapp_type: app.globalData.miniapp_type,
|
|
|
formId: formId,
|
|
|
method: 'wechat.formId.add',
|
|
|
}
|
|
|
// console.log('params', formIdParams)
|
|
|
api.get({data: formIdParams})
|
|
|
},
|
|
|
|
|
|
getRefundSeason: function () {
|
|
|
let param = {
|
|
|
method: 'app.SpaceOrders.refundApplyReasons',
|
|
|
fromPage: 'aFP_MineOrderContent'
|
|
|
}
|
|
|
|
|
|
api.get({data: param})
|
|
|
.then(json => {
|
|
|
if (json && json.code == 200) {
|
|
|
// console.log('退货理由获取成功')
|
|
|
this.setData({
|
|
|
refundReason: json.data
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
/**
|
|
|
* 再次购买
|
|
|
*/
|
|
|
onReaddTapped: function (e) {
|
|
|
// console.log("再次购买tab");
|
|
|
var code = e.currentTarget.dataset.order_code;
|
|
|
var that = this;
|
|
|
tt.showModal({
|
|
|
title: '确认将商品再次加入购物车?',
|
|
|
cancelText: '取消',
|
|
|
confirmText: '确定',
|
|
|
confirmColor: '#FF0000',
|
|
|
success: function (res) {
|
|
|
if (res.confirm) {
|
|
|
// console.log("Click confirm button");
|
|
|
let param = {
|
|
|
method: "app.Shopping.readd",
|
|
|
order_code: code,
|
|
|
fromPage: "aFP_MineOrderContent"
|
|
|
}
|
|
|
api.get({data: param})
|
|
|
.then(json => {
|
|
|
if (json && json.code && json.code == 200) {
|
|
|
tt.showToast({
|
|
|
title: '加入购物车成功',
|
|
|
complete: function () {
|
|
|
tt.switchTab({
|
|
|
url: '../../shopCart/shopCart',
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
//申请退款
|
|
|
onRefundApplyTapped: function (e) {
|
|
|
let that = this;
|
|
|
var code = e.currentTarget.dataset.order_code;
|
|
|
that.setData({
|
|
|
order_code:code,
|
|
|
})
|
|
|
tt.showModal({
|
|
|
content: '申请退款后,本单享有的优惠可能会一并取消,确定申请吗?',
|
|
|
cancelText: '取消',
|
|
|
confirmText: '确定',
|
|
|
confirmColor: '#FF0000',
|
|
|
success: function (res) {
|
|
|
if (res.confirm) {
|
|
|
// console.log('用户点击确定')
|
|
|
that.setData({
|
|
|
showReason: true,
|
|
|
reFaudCode: code,
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
chooseReason: function (e) {
|
|
|
|
|
|
let app = getApp();
|
|
|
let _self = this;
|
|
|
let reason_id = e.currentTarget.dataset.id;
|
|
|
let reason = e.currentTarget.dataset.reason;
|
|
|
let order_code = this.data.reFaudCode;
|
|
|
if (order_code) {
|
|
|
_self.setData({
|
|
|
order_code,
|
|
|
})
|
|
|
|
|
|
let param = {
|
|
|
method: 'app.SpaceOrders.refundApply',
|
|
|
reason_id,
|
|
|
reason,
|
|
|
order_code,
|
|
|
fromPage: "aFP_MineOrderContent",
|
|
|
miniapp_type: app.globalData.miniapp_type,
|
|
|
}
|
|
|
api.get({data: param})
|
|
|
.then(json => {
|
|
|
this.hidderPicker();
|
|
|
if (json && json.code == 200) {
|
|
|
tt.navigateBack({
|
|
|
delta:1
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
.catch(error => {
|
|
|
this.hidderPicker();
|
|
|
})
|
|
|
}
|
|
|
|
|
|
},
|
|
|
//picker-view的监听
|
|
|
bindChange:function(e){
|
|
|
// console.log(e);
|
|
|
let value = e.detail.value;
|
|
|
this.setData({
|
|
|
reasonIndex:value[0]
|
|
|
})
|
|
|
},
|
|
|
//选定退货理由
|
|
|
reasonSure:function(e){
|
|
|
// console.log('选定退货理由');
|
|
|
if (!this.data.refundReason || this.data.refundReason.length<0){
|
|
|
return;
|
|
|
}
|
|
|
let reasonIndex = this.data.reasonIndex;
|
|
|
|
|
|
// console.log("下标" + reasonIndex)
|
|
|
let reason_id = this.data.refundReason[reasonIndex].id;
|
|
|
let reason = this.data.refundReason[reasonIndex].reason;
|
|
|
let order_code = this.data.reFaudCode;
|
|
|
this.setData({
|
|
|
reasonIndex:0,
|
|
|
order_code: order_code,
|
|
|
})
|
|
|
if (order_code) {
|
|
|
let param = {
|
|
|
method: 'app.SpaceOrders.refundApply',
|
|
|
reason_id,
|
|
|
reason,
|
|
|
order_code,
|
|
|
fromPage: "aFP_MineOrderContent"
|
|
|
}
|
|
|
api.get({data: param})
|
|
|
.then(json => {
|
|
|
this.hidderPicker();
|
|
|
if (json && json.code == 200) {
|
|
|
tt.navigateBack({
|
|
|
delta: 1
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
.catch(error => {
|
|
|
this.hidderPicker();
|
|
|
})
|
|
|
}
|
|
|
|
|
|
},
|
|
|
hidderPicker: function () {
|
|
|
this.setData({
|
|
|
showReason: false,
|
|
|
reFaudCode: ''
|
|
|
})
|
|
|
},
|
|
|
add0: function(m) {
|
|
|
return m<10?'0'+m:m
|
|
|
},
|
|
|
formatDate: function(shijianchuo) {
|
|
|
var time = new Date(shijianchuo * 1000);
|
|
|
var y = time.getFullYear();
|
|
|
var m = time.getMonth()+1;
|
|
|
var d = time.getDate();
|
|
|
var h = time.getHours();
|
|
|
var mm = time.getMinutes();
|
|
|
var s = time.getSeconds();
|
|
|
return y + '-' + this.add0(m) + '-' + this.add0(d) + ' ' + this.add0(h) + ':' + this.add0(mm) + ':' + this.add0(s);
|
|
|
},
|
|
|
formatImgUrl: function(json) {
|
|
|
json.data.order_goods && json.data.order_goods.map((item, index) => {
|
|
|
let replaceStr = "{width}";
|
|
|
let url = item.goods_image;
|
|
|
let real_pay_price = item.real_pay_price;
|
|
|
let goods_price = item.goods_price;
|
|
|
let goods_sale_price = item.sales_price;
|
|
|
|
|
|
if (new Number(real_pay_price).toFixed(2) == new Number(goods_sale_price) || !real_pay_price){
|
|
|
item.real_pay_price = item.goods_price ? item.goods_price : item.sales_price;
|
|
|
item.sales_price = '';
|
|
|
}
|
|
|
if (item.sales_price){
|
|
|
item.sales_price = new Number(item.sales_price).toFixed(2);
|
|
|
}
|
|
|
url = url.replace(new RegExp('{width}', 'gm'), '65').replace(new RegExp('{height}', 'gm'), '100');
|
|
|
item.goods_image = url;
|
|
|
});
|
|
|
|
|
|
// console.log(json);
|
|
|
},
|
|
|
|
|
|
getDetail:function (order_code) {
|
|
|
let param = {
|
|
|
method: APP_SPACEORDERS_DETAIL,
|
|
|
order_code: order_code,
|
|
|
uid: app.getUid()
|
|
|
}
|
|
|
|
|
|
api.get({data: param})
|
|
|
.then(json => {
|
|
|
tt.hideLoading();
|
|
|
this.setData({
|
|
|
isLoading: false,
|
|
|
});
|
|
|
if (json && json.code && json.code == 200) {
|
|
|
|
|
|
this.formatImgUrl(json);
|
|
|
let requestOK = true;
|
|
|
let needTimer = false;
|
|
|
let pay_lefttime = 0;
|
|
|
|
|
|
if (json.data.order_detail_info && json.data.order_detail_info.ext && json.data.order_detail_info.ext.need_create === 'Y'){
|
|
|
needTimer = true;
|
|
|
pay_lefttime = parseInt(json.data.order_detail_info.ext.pay_lefttime);
|
|
|
}
|
|
|
|
|
|
let isShowExpress = false;
|
|
|
if (json.data.links && json.data.links.length > 0){
|
|
|
for (var i = 0;i < json.data.links.length;i++){
|
|
|
if (json.data.links[i] === "getExpress"){
|
|
|
isShowExpress = true;
|
|
|
break;
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
this.setData({
|
|
|
data: json.data,
|
|
|
requestOK: true,
|
|
|
pay_lefttime,
|
|
|
isShowExpress,
|
|
|
});
|
|
|
|
|
|
if (needTimer) {
|
|
|
this.stopTimer();
|
|
|
this.startTimer();
|
|
|
} else {
|
|
|
this.stopTimer();
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
.catch(error => {
|
|
|
tt.hideLoading();
|
|
|
this.setData({
|
|
|
isLoading: false,
|
|
|
});
|
|
|
});
|
|
|
},
|
|
|
onLoad:function(options){
|
|
|
// 生命周期函数--监听页面加载
|
|
|
let from_page_name = options.page_name ? options.page_name : '';
|
|
|
let from_page_param = options.page_param ? options.page_param : '';
|
|
|
let current_page_param = options.order_code;
|
|
|
this.setData({
|
|
|
order_code: options.order_code,
|
|
|
from_page_name, from_page_param, current_page_param,
|
|
|
isShowHomeNav: app.globalData.currentScene === 1014 || app.globalData.currentScene === "1014",
|
|
|
});
|
|
|
|
|
|
this.loadEnvelopesData();
|
|
|
var pages = getCurrentPages()
|
|
|
var currentPage = pages[pages.length - 1]
|
|
|
var url = currentPage.route
|
|
|
|
|
|
// let params = {
|
|
|
// PAGE_NAME: this.data.current_page_name,
|
|
|
// PAGE_PARAM: this.data.current_page_param,
|
|
|
// FROM_PAGE_NAME: this.data.from_page_name,
|
|
|
// FROM_PAGE_PARAM: this.data.from_page_param,
|
|
|
// PAGE_PATH: url
|
|
|
// };
|
|
|
// logEvent(YB_PAGE_OPEN_L, params);
|
|
|
|
|
|
// //订阅登录完成通知
|
|
|
// listen(function (succeed) {
|
|
|
// if (succeed) {
|
|
|
// this.getDetail(this.data.order_code);
|
|
|
// } else {
|
|
|
// let app = getApp()
|
|
|
// if (!app.getUid() || app.getUid() === 0) {
|
|
|
// tt.switchTab({
|
|
|
// url: '../../userCenter/userCenter',
|
|
|
// })
|
|
|
// }
|
|
|
// }
|
|
|
// }.bind(this))
|
|
|
|
|
|
},
|
|
|
onReady:function(){
|
|
|
// 生命周期函数--监听页面初次渲染完成
|
|
|
},
|
|
|
onShow:function(){
|
|
|
// 生命周期函数--监听页面显示
|
|
|
tt.showLoading({
|
|
|
title: '加载中...',
|
|
|
})
|
|
|
this.setData({
|
|
|
isLoading: true,
|
|
|
});
|
|
|
this.getDetail(this.data.order_code);
|
|
|
this.getRecommed();
|
|
|
this.getRefundSeason();
|
|
|
this.getResources();
|
|
|
},
|
|
|
onHide:function(){
|
|
|
// 生命周期函数--监听页面隐藏
|
|
|
this.stopTimer();
|
|
|
},
|
|
|
onUnload:function(){
|
|
|
// 生命周期函数--监听页面卸载
|
|
|
this.stopTimer();
|
|
|
},
|
|
|
onPullDownRefresh: function() {
|
|
|
// // 页面相关事件处理函数--监听用户下拉动作
|
|
|
// let params = {
|
|
|
// PAGE_NAME: this.data.current_page_name,
|
|
|
// PAGE_PARAM: this.data.current_page_param,
|
|
|
// FROM_PAGE_NAME: this.data.from_page_name,
|
|
|
// FROM_PAGE_PARAM: this.data.from_page_param,
|
|
|
// };
|
|
|
// logEvent(YB_PAGE_OPEN_L, params);
|
|
|
},
|
|
|
onReachBottom: function() {
|
|
|
// 页面上拉触底事件的处理函数
|
|
|
},
|
|
|
onExpressTapped: function (e) {
|
|
|
var code = e.currentTarget.dataset.order_code;
|
|
|
// console.log("查看物流");
|
|
|
tt.navigateTo({
|
|
|
url: '../../logisticsDetails/logisticsDetails?order_code=' + code,
|
|
|
})
|
|
|
},
|
|
|
/**
|
|
|
* 取消订单
|
|
|
*/
|
|
|
onCloseOrderTapped: function(e) {
|
|
|
var code = e.currentTarget.dataset.order_code;
|
|
|
var app = getApp();
|
|
|
var _self = this;
|
|
|
|
|
|
_self.setData({
|
|
|
order_code:code,
|
|
|
})
|
|
|
|
|
|
tt.showModal({
|
|
|
title: '取消订单',
|
|
|
content: '订单取消后不能恢复,确认取消此订单么?',
|
|
|
cancelText: '返回',
|
|
|
confirmText: '取消订单',
|
|
|
confirmColor: "#000000",
|
|
|
success: function(res) {
|
|
|
if (res.confirm) {
|
|
|
let param = {
|
|
|
method: APP_SPACEORDERS_CLOSE,
|
|
|
order_code: code,
|
|
|
uid: app.getUid(),
|
|
|
miniapp_type: app.globalData.miniapp_type,
|
|
|
}
|
|
|
api.get({data: param})
|
|
|
.then((json) => {
|
|
|
if (json && json.code && json.code == 200) {
|
|
|
tt.navigateBack({
|
|
|
delta: 1
|
|
|
})
|
|
|
}
|
|
|
else if (json && json.code && json.code != 200){
|
|
|
tt.showModal({title: json.message, showCancel:false})
|
|
|
}
|
|
|
})
|
|
|
.catch(error => {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
/**
|
|
|
* 确认收货
|
|
|
*/
|
|
|
onConfirmTapped: function(e) {
|
|
|
var code = e.currentTarget.dataset.order_code;
|
|
|
var _self = this;
|
|
|
var app = getApp()
|
|
|
|
|
|
tt.showModal({
|
|
|
title: '确认收货',
|
|
|
content: '请确认是否已经收到商品?',
|
|
|
cancelText: '取消',
|
|
|
confirmText: '确定',
|
|
|
confirmColor: '#FF0000',
|
|
|
success: function(res) {
|
|
|
if (res.confirm) {
|
|
|
let param = {
|
|
|
method: APP_SPACEORDERS_CONFIRM,
|
|
|
order_code: code,
|
|
|
uid: app.getUid(),
|
|
|
miniapp_type: app.globalData.miniapp_type,
|
|
|
|
|
|
}
|
|
|
api.get({data: param})
|
|
|
.then((json) => {
|
|
|
if (json && json.code && json.code == 200) {
|
|
|
tt.navigateBack({
|
|
|
delta: 1
|
|
|
})
|
|
|
}
|
|
|
else {
|
|
|
|
|
|
}
|
|
|
})
|
|
|
.catch(error => {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
//拼团购商品 点击立即购买
|
|
|
onBuyFromApp: function (e) {
|
|
|
tt.showModal({
|
|
|
title: '提示',
|
|
|
content: "拼团订单只能在APP支付,请在应用市场搜索下载“Yoho!buy有货”,使用微信登录完成支付",
|
|
|
confirmText: '确定',
|
|
|
showCancel: false,
|
|
|
success: function (res) {
|
|
|
if (res.confirm) {
|
|
|
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
/**
|
|
|
* 立即付款
|
|
|
*/
|
|
|
onBuyNowTapped: function(e) {
|
|
|
// let mCode = e.target.dataset.order_code;
|
|
|
// let group_no = e.target.dataset.group_no ? e.target.dataset.group_no : '';
|
|
|
// let activity_id = e.target.dataset.activity_id ? e.target.dataset.activity_id : '';
|
|
|
// let mOrder = {};
|
|
|
// let payParam = {};
|
|
|
// if (group_no && group_no != ''){
|
|
|
// payParam = {
|
|
|
// group_no,
|
|
|
// activity_id,
|
|
|
// fromPage:"groupPurchaseDetail"
|
|
|
// }
|
|
|
// }
|
|
|
// mOrder.order_code = mCode;
|
|
|
// wexinPay(mOrder,payParam)
|
|
|
},
|
|
|
/**
|
|
|
* 删除订单
|
|
|
*/
|
|
|
onDelOrderTapped: function(e) {
|
|
|
var code = e.currentTarget.dataset.order_code;
|
|
|
var _self = this;
|
|
|
tt.showModal({
|
|
|
content: '确认删除订单?',
|
|
|
cancelText: '取消',
|
|
|
confirmText: '确定',
|
|
|
confirmColor: '#FF0000',
|
|
|
success: function(res) {
|
|
|
if (res.confirm) {
|
|
|
let param = {
|
|
|
method: APP_SPACEORDERS_DELORDERBYCODE,
|
|
|
order_code: code,
|
|
|
uid: app.getUid()
|
|
|
}
|
|
|
api.get({data: param})
|
|
|
.then((json) => {
|
|
|
if (json && json.code && json.code == 200) {
|
|
|
tt.navigateBack({
|
|
|
delta: 1
|
|
|
})
|
|
|
}
|
|
|
})
|
|
|
.catch(error => {
|
|
|
})
|
|
|
}
|
|
|
}
|
|
|
})
|
|
|
},
|
|
|
/**
|
|
|
* 申请售后
|
|
|
*/
|
|
|
onAfterServiceTapped: function(e) {
|
|
|
tt.showModal({
|
|
|
title: '提示',
|
|
|
content: '小程序暂不支持退换货,请使用有货APP或官网退换货!',
|
|
|
showCancel: false,
|
|
|
confirmText: '确定',
|
|
|
})
|
|
|
},
|
|
|
changeAddress: function() {
|
|
|
|
|
|
// console.log(this.data.data.can_update_delivery_address)
|
|
|
// this.data.data.can_update_delivery_address == "Y" 不让在订单详情页 修改地址
|
|
|
if (false) {
|
|
|
//可以点击进入换地址
|
|
|
tt.navigateTo({
|
|
|
url: '../../addressManager/addressManager?currentMode=modeChange&order_code=' + this.data.data.order_code + '&page_name=' + this.data.current_page_name + '&page_param=' + this.data.current_page_param
|
|
|
})
|
|
|
}
|
|
|
else {
|
|
|
|
|
|
}
|
|
|
},
|
|
|
selectComplete: function(json) {
|
|
|
// console.log(json);
|
|
|
},
|
|
|
goTODefraudPage: function () {
|
|
|
// console.log("订单详情页跳转到防诈骗页面");
|
|
|
tt.navigateTo({
|
|
|
url: '../../antifraud/antifraud',
|
|
|
})
|
|
|
},
|
|
|
|
|
|
//获取红包信息
|
|
|
loadEnvelopesData: function () {
|
|
|
let app = getApp();
|
|
|
let that = this;
|
|
|
let param = {
|
|
|
// method: 'app.activity.payActivityProfile',
|
|
|
// uid: '500029682',//app.getUid(),
|
|
|
// orderCode: '1701060848',//this.data.orderCode,
|
|
|
// debug: 'XYZ',
|
|
|
|
|
|
method: 'app.activity.payActivityProfile',
|
|
|
uid: app.getUid(),
|
|
|
orderCode: this.data.order_code,
|
|
|
};
|
|
|
|
|
|
|
|
|
api.get({data: param})
|
|
|
.then(function (data) {
|
|
|
if (data && data.code == 200) {
|
|
|
|
|
|
let activityBanner = data.data.activityBanner.replace(/{width}/, bannerWidth).replace(/{height}/, bannerHeight);
|
|
|
let token = data.data.token;
|
|
|
|
|
|
that.setData({
|
|
|
activityBanner,
|
|
|
token,
|
|
|
});
|
|
|
|
|
|
} else {
|
|
|
}
|
|
|
})
|
|
|
.catch(function (error) {
|
|
|
});
|
|
|
},
|
|
|
|
|
|
onShareAppMessage: function (res) {
|
|
|
let param = {
|
|
|
FROM: res.from,
|
|
|
SHARE_RESUIL: 0,
|
|
|
TITLE: '我在有货给你发红包啦,专属好礼送不停!',
|
|
|
PATH: '/pages/envelopesActivity/envelopesActivity?token=' + this.data.token,
|
|
|
}
|
|
|
return {
|
|
|
title: param.TITLE,
|
|
|
path: param.PATH,
|
|
|
imageUrl: 'https://cdn.yoho.cn/20171218/fenxianghongbao.png',
|
|
|
success: function (res) {
|
|
|
// param.SHARE_RESUIL = 1
|
|
|
// logEvent(YB_SHARE_RESULT_L, param);
|
|
|
},
|
|
|
fail: function (res) {
|
|
|
// param.SHARE_RESUIL = 2
|
|
|
// logEvent(YB_SHARE_RESULT_L, param);
|
|
|
}
|
|
|
}
|
|
|
},
|
|
|
|
|
|
|
|
|
startTimer: function (e) {
|
|
|
let that = this;
|
|
|
timer = setInterval(function () {
|
|
|
let pay_lefttime = that.data.pay_lefttime;
|
|
|
let time_left = '';
|
|
|
if (pay_lefttime > 0) {
|
|
|
pay_lefttime = pay_lefttime - 1;
|
|
|
time_left = that.formatDateForTimer(pay_lefttime);
|
|
|
if (pay_lefttime == 0) {
|
|
|
that.getDetail(that.data.order_code);
|
|
|
}
|
|
|
} else {
|
|
|
pay_lefttime = 0;
|
|
|
}
|
|
|
|
|
|
that.setData({
|
|
|
pay_lefttime,
|
|
|
time_left,
|
|
|
})
|
|
|
}, 1000);
|
|
|
},
|
|
|
|
|
|
stopTimer: function (e) {
|
|
|
// console.log('stopTimer');
|
|
|
clearInterval(timer);
|
|
|
},
|
|
|
|
|
|
formatDateForTimer: function (second) {
|
|
|
var dateStr = "";
|
|
|
var hr = Math.floor(second / 3600);
|
|
|
var min = Math.floor((second - hr * 3600) / 60);
|
|
|
var sec = (second - hr * 3600 - min * 60);// equal to => var sec = second % 60;
|
|
|
dateStr = this.add0(hr) + ":" + this.add0(min) + ":" + this.add0(sec);
|
|
|
return dateStr;
|
|
|
},
|
|
|
gotoGroupBuyDetail: function (res) {
|
|
|
let target = res.target;
|
|
|
let group_no = res.target.dataset.group_no ? res.target.dataset.group_no : '';
|
|
|
let activity_id = res.target.dataset.activity_id ? res.target.dataset.activity_id : '';
|
|
|
tt.navigateTo({
|
|
|
url: "../../groupPurchase/groupPurchaseResult?activity_id=" + activity_id + '&group_no=' + group_no + '&page_name=' + 'orderDetail' + '&page_param=' + this.data.current_page_param
|
|
|
});
|
|
|
},
|
|
|
|
|
|
/**
|
|
|
* 为你优选
|
|
|
*/
|
|
|
getRecommed: function () {
|
|
|
let gender = getGenderCode(getApp().globalData.selectedChannel);
|
|
|
let yh_channel = getChannelCode(getApp().globalData.selectedChannel);
|
|
|
let param = {
|
|
|
method: "app.home.newPreference",
|
|
|
gender,
|
|
|
yh_channel,
|
|
|
rec_pos: 100004,
|
|
|
limit: 30,
|
|
|
fromPage: "aFP_My",
|
|
|
}
|
|
|
api.get({data: param})
|
|
|
.then(json => {
|
|
|
if (json && json.code && json.code == 200) {
|
|
|
|
|
|
let data = json.data.product_list;
|
|
|
data = parseBrandListData(data);
|
|
|
this.setData({
|
|
|
recommdData: data,
|
|
|
})
|
|
|
}
|
|
|
});
|
|
|
},
|
|
|
|
|
|
copy: function (e) {
|
|
|
var that = this;
|
|
|
var content = e.currentTarget.dataset.copy_content;
|
|
|
var type = e.currentTarget.dataset.copy_type;
|
|
|
tt.setClipboardData({
|
|
|
data: '' + content,
|
|
|
})
|
|
|
},
|
|
|
|
|
|
lookup: function (e) {
|
|
|
var that = this;
|
|
|
var copy_url = e.currentTarget.dataset.copy_url;
|
|
|
var copy_content = e.currentTarget.dataset.copy_content;
|
|
|
var copy_type = e.currentTarget.dataset.copy_type;
|
|
|
tt.setClipboardData({
|
|
|
data: '' + copy_url,
|
|
|
success: function (res) {
|
|
|
tt.hideToast();
|
|
|
},
|
|
|
})
|
|
|
tt.showModal({
|
|
|
title: '',
|
|
|
content: copy_content,
|
|
|
showCancel: false,
|
|
|
})
|
|
|
},
|
|
|
|
|
|
getResources: function () {
|
|
|
let that = this;
|
|
|
api.get({
|
|
|
url: '/operations/api/v5/resource/get',
|
|
|
data: {
|
|
|
content_code: "384329629395526cdb4c8bbb7be4d619"
|
|
|
},})
|
|
|
.then(json => {
|
|
|
if (json && json.code && json.code == 200 && json.data) {
|
|
|
for(var i = 0;i < json.data.length;i++){
|
|
|
//图片url转换
|
|
|
if(json.data[i] && json.data[i].data && json.data[i].data.list){
|
|
|
for (var j = 0;j < json.data[i].data.list.length; j++){
|
|
|
json.data[i].data.list[j].src = json.data[i].data.list[j].src.replace('{width}', json.data[i].data.imageWidth).replace('{height}', json.data[i].data.imageHeight).replace('{mode}',2);
|
|
|
// json.data[i].data.list[j].src = getImageUrlWithWH(json.data[i].data.list[j].src, windowWidth, windowWidth * json.data[i].data.imageHeight /json.data[i].data.imageWidth);
|
|
|
}
|
|
|
}
|
|
|
//图片宽高转换(为什么这个写法可行还需要再研究)
|
|
|
if (json.data[i] && json.data[i].data && json.data[i].data.imageHeight && json.data[i].data.imageWidth){
|
|
|
json.data[i].data.imageHeight = parseInt(json.data[i].data.imageHeight) / parseInt(json.data[i].data.imageWidth) * 750;//rpx
|
|
|
json.data[i].data.imageWidth = 750;//750rpx是固定的设计标准
|
|
|
}
|
|
|
}
|
|
|
that.setData({
|
|
|
resources: json.data,
|
|
|
});
|
|
|
}
|
|
|
}).catch(error => {});
|
|
|
},
|
|
|
}) |
|
|
\ No newline at end of file |
...
|
...
|
|