209 lines
4.9 KiB
JavaScript
209 lines
4.9 KiB
JavaScript
// packageA/mycomponent/goods_telephone_charges_pro/goods_telephone_charges_pro.js
|
|
var app = getApp();
|
|
let cache_account = "";
|
|
Component({
|
|
/**
|
|
* 组件的属性列表
|
|
*/
|
|
properties: {
|
|
prop_goods_info: {
|
|
type: null, //父组件的商品详情数据
|
|
},
|
|
goodsId: {
|
|
type: Number,
|
|
},
|
|
goodsType: {
|
|
type: String,
|
|
},
|
|
hoet: {
|
|
type: null,
|
|
},
|
|
},
|
|
|
|
/**
|
|
* 组件的初始数据
|
|
*/
|
|
data: {
|
|
goodsInfo: {},
|
|
|
|
rechargeType: {},
|
|
rechargeItem: {},
|
|
rechargeSpecId: 0,
|
|
|
|
displayOptions: [],
|
|
optionsId: 0,
|
|
|
|
show1: false,
|
|
service_QRcode: "",
|
|
service_mobile: "",
|
|
cservice: "",
|
|
|
|
mobile: "",
|
|
account:"",
|
|
mobile_disabled:false,
|
|
|
|
bannerUrl: "",
|
|
|
|
posterShow: false,
|
|
|
|
},
|
|
ready() {
|
|
cache_account = "";
|
|
let prop_goods_info = this.properties.prop_goods_info;
|
|
let changeData = {};
|
|
let goodsInfo = this.data.goodsInfo = prop_goods_info.get_goods;
|
|
let rechargeType = goodsInfo.has_many_specs[0];
|
|
this._handClickSpecs(rechargeType.specitem[0]);
|
|
changeData.goodsInfo = goodsInfo;
|
|
changeData.rechargeType = rechargeType;
|
|
//轮播图
|
|
if (prop_goods_info && prop_goods_info.plugin && prop_goods_info.plugin.oilRechargeGoods) {
|
|
changeData.bannerUrl = prop_goods_info.plugin.oilRechargeGoods.banner;
|
|
}
|
|
|
|
//客服相关
|
|
if (prop_goods_info.customer_service) {
|
|
// 客服
|
|
changeData.service_QRcode = prop_goods_info.customer_service.service_QRcode;
|
|
changeData.service_mobile = prop_goods_info.customer_service.service_mobile;
|
|
changeData.cservice = prop_goods_info.customer_service.cservice;
|
|
}
|
|
|
|
this.setData(changeData);
|
|
},
|
|
/**
|
|
* 组件的方法列表
|
|
*/
|
|
methods: {
|
|
handClickSpecs(evt) {
|
|
let item = evt.currentTarget.dataset.item;
|
|
this._handClickSpecs(item);
|
|
},
|
|
_handClickSpecs(item) {
|
|
if (this.data.rechargeSpecId == item.id) return;
|
|
let has_many_options = this.data.goodsInfo.has_many_options;
|
|
let arr = [];
|
|
for (let i = 0; i < has_many_options.length; i++) {
|
|
if (has_many_options[i].specs.indexOf(item.id) >= 0) {
|
|
arr.push(has_many_options[i]);
|
|
}
|
|
}
|
|
this.setData({
|
|
rechargeSpecId: item.id,
|
|
rechargeItem: item,
|
|
displayOptions: arr,
|
|
optionsId: 0
|
|
});
|
|
},
|
|
|
|
handClickOptions(evt) {
|
|
let item = evt.currentTarget.dataset.item;
|
|
this.setData({
|
|
optionsId: item.id
|
|
});
|
|
},
|
|
gotoDetailV2(evt){
|
|
let id = evt.currentTarget.dataset.id;
|
|
wx.navigateTo({
|
|
url: '/packageA/detail_v2/detail_v2?id='+id,
|
|
});
|
|
},
|
|
gotoChat(evt) {
|
|
let url = evt.currentTarget.dataset.cservice + "&goods_id=" + this.data.goodsId;
|
|
wx.navigateTo({
|
|
url: url,
|
|
fail: (err) => {
|
|
app.tips("客服路由出错");
|
|
}
|
|
});
|
|
},
|
|
|
|
setCserviceFlag(){
|
|
this.setData({
|
|
show1:!this.data.show1
|
|
});
|
|
},
|
|
|
|
gotoOrderList(){
|
|
wx.navigateTo({
|
|
url: '/packageA/member/myOrder_v2/myOrder_v2',
|
|
});
|
|
},
|
|
|
|
gotoIndex(){
|
|
wx.reLaunch({
|
|
url: '/packageG/index/index',
|
|
});
|
|
},
|
|
|
|
setPosterShow(){
|
|
this.setData({
|
|
posterShow:true
|
|
});
|
|
},
|
|
setTopping() {
|
|
wx.pageScrollTo({
|
|
scrollTop: 0
|
|
});
|
|
},
|
|
|
|
getMobileByAccount(type){
|
|
if(cache_account == this.data.account){
|
|
if(type === 1){
|
|
this.gotoGoodsOrder();
|
|
}
|
|
return;
|
|
}
|
|
let urlStr = app.getNetAddresss('plugin.oil-recharge.frontend.index.getMobileByAccount');
|
|
app._postNetWork({
|
|
url: urlStr,
|
|
data:{account:this.data.account},
|
|
success: (resdata) => {
|
|
var res = resdata.data;
|
|
if (res.result != 1) return app.tips(res.msg);
|
|
let mobile = res.data.mobile;
|
|
if (mobile == "") {
|
|
this.setData({mobile_disabled:false})
|
|
} else {
|
|
this.setData({mobile_disabled:true,mobile})
|
|
}
|
|
cache_account = this.data.account;
|
|
if(type === 1){
|
|
this.gotoGoodsOrder();
|
|
}
|
|
}
|
|
});
|
|
|
|
},
|
|
|
|
sendRecharge() {
|
|
// 手机慢充
|
|
let {mobile,goodsId,optionsId} = this.data;
|
|
if (!mobile) {
|
|
app.tips("请输入充值手机号码!");
|
|
return false;
|
|
} else {
|
|
let reg_txt = /^[1][0-9]{10}$/;
|
|
if (!reg_txt.test(mobile)) {
|
|
app.tips("请输入正确的充值手机号码!");
|
|
return false;
|
|
}
|
|
}
|
|
if (optionsId <= 0) return app.tips("请选择规格ID");
|
|
|
|
this.getMobileByAccount(1);
|
|
},
|
|
|
|
gotoGoodsOrder(){
|
|
let {mobile,goodsId,optionsId,account} = this.data;
|
|
wx.navigateTo({
|
|
url: "/packageD/buy/myOrder_v2/myOrder_v2?tag=-2&total=1&&goodsId=" + goodsId + "&optionsId=" + optionsId + "&oil_mobile=" + mobile + "&oil_account=" + account,
|
|
});
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
}); |