var e = getApp(),
a = e.globalData.setting,
os = a,
t = e.request,
d = e.globalData;
var ut = require("../../../utils/util.js");
var com = require("../public/buy_com.js");
Page({
data: {
url: a.url, //接口网址
iurl: a.imghost, //图片前缀网址
isBuy: 0,
getGiftID: '', //礼包id
giftImage: '',
giftTitle: '',
giftDate: '',
giftPrice: '',
giftIntegral: '',
giftPosPrice: '',
giftQty: '',
giftRemark: '',
giftType: '',
actTitle: '',
getUrl: '',
wareCard: [],
orderSn: "", //订单编号
lbId: "",
code: "", //核销码
c_state: "0", //判断是否已经使用, 0正常 1已使用 2已过期
is_lb: 0, //是否有礼包
default_color: null,
first_leader: e.globalData.first_leader || 0, // 推荐人ID
//门店相关
ismend: 0,
is_sec_mend: 0,
sto_sele_name: "", //选中的门店名称
sto_sele_id: "", //选中的门店id
sto_sele_distr: "", //选择的门店的配送方式
is_show_sto_cat: 1, //是否显示门店分类
only_pk: null,
all_sto: null,
sec_sto: null, //选择了的门店分类
pickpu_list: null, //读出的所有门店list
def_pickpu_list: null, //一开始5个门店list
sec_pick_index: 0, //第二级门店选择ID
fir_pick_index: 0, //第一级门店选择ID
all_pick_list: null,//所有的门店先记录起来
select_store: 0, //选择更多
index: 1,
more_store: 0, //选择门店
sort_store: 0, //门店分类
choice_sort_store: 0, //选择分类门店
new_user: 0, //新用户
def_pick_store: null, // 默认的门店
fir_def_store: null, //客户默认的门店的
lat: null, //维度
lon: null, //经度
is_get_local_ok: 0, //获取坐标是否完成
region_name: "门店分类", //区域的名字
is_gps: 1,
open_ind_store: 0, //哪里打开的门店列表的控制属性
default_store: {}, //创建添加默认门店地址的对象
store:0,
openSpecModal:0
},
onLoad: function (options) {
var th=this;
this.setData({
params:options,
})
getApp().getConfig2(function (e) {
var json_d = JSON.parse(e.switch_list);
th.setData({
bconfig: e,
sys_switch:json_d
});
})
},
init(){
let options = this.data?.params; // this.data == null ? undefined:this.data.params
var th = this;
this.setData({
getUserID: d.user_id,
getStorageID: a.stoid,
})
this.setData({
isBuy: options.isBuy,
getGiftID: options.lbId,
orderSn: options.orderSn,
flag: options.flag, // 如果从商品详情页的促销处点击专享礼包跳转到此页,则flag为1
})
if (options.lbId) th.data.lbId = options.lbId;
//-- 获取分享人的ID --
var first_leader = options.first_leader || getApp().globalData.first_leader;
if (first_leader) {
this.setData({
first_leader,
})
//-- user_id代过来免登录 --
getApp().globalData.first_leader = first_leader;
//调用接口判断是不是会员
getApp().request.promiseGet("/api/weshop/shoppingGuide/get/" + os.stoid + "/" + first_leader, {}).then(res => {
if (res.data.code == 0) {
getApp().globalData.guide_id = res.data.data.id;
}
})
}
th.close();
if(this.data.flag == 1) {
this.getZxlbDetails();
} else {
if (this.data.isBuy == 0) {
this.GetMyGiftList();
} else if (this.data.isBuy == 1) {
this.GetBuyGiftList();
};
};
},
onShow: function () {
getApp().check_can_share();
getApp().is_Single_page(this,function () {
//--先判断会员状态--
var user_info = getApp().globalData.userInfo;
if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
getApp().goto('/pages/togoin/togoin');
return false;
}
this.init();
})
},
GetBuyPrice: function (e) {
var that = this.data;
var th = this;
//如果还没有开始的话
if (th.data.isStart != 1) {
getApp().my_warnning("活动还没有开始", 0, th);
return false;
}
this.data.payMoney=th.data.sele_g.payMoney;
th.setData({ buyType:2 })
if(th.data.sele_g.is_pickup){
th.setData({
openSpecModal:1
})
}else{
var my_confirm = th.selectComponent("#my_confirm"); //组件的id
my_confirm.open(
"是否确定购买该礼包",
"取消",
"确定",
function () {
my_confirm.open_cancel(0);
},
function () {
my_confirm.open_cancel(0);
com.buy_libao(th)
}
)
}
},
GetBuyIntegral: function (e) {
var that = this.data;
var th = this;
//如果还没有开始的话
if (th.data.isStart != 1) {
getApp().my_warnning("活动还没有开始", 0, th);
return false;
}
th.setData({ buyType:1 });
if(th.data.sele_g.is_pickup){
th.setData({
openSpecModal:1
})
}else {
var my_confirm = th.selectComponent("#my_confirm"); //组件的id
my_confirm.open(
"是否确定兑换该礼包",
"取消",
"确定",
function () {
my_confirm.open_cancel(0);
},
function () {
my_confirm.open_cancel(0);
com.buy_libao(th)
})
}
},
GetMyGiftList: function () {
var _this = this;
var th = this;
getApp().request.get('/api/weshop/marketing/my/giftbag/detail/get', {
isShowLoading: true,
data: {
"storeId": a.stoid, //商家ID
"userId": d.user_id, //用户ID
"orderSn": th.data.orderSn
},
success: function (res) {
if (res.data.code == 0) {
th.setData({
giftImage: th.data.iurl + res.data.data.lbUrl,
giftTitle: res.data.data.giftTitle,
default_color: res.data.data.bgcolor
})
if(res.data.data.iswarelbtype==1) {
th.setData({iswarelbtype:1})
}
if (!res.data.data.giftRemark || res.data.data.giftRemark == '') {
th.setData({
giftRemark: '暂无详情......'
})
} else {
th.setData({
giftRemark: res.data.data.giftRemark.replace(/\
t_now)
th.setData({
c_state: -1
})
th.setData({
giftDate: res.data.data.endTime,
giftPosPrice: res.data.data.giftPosPrice,
giftQty: res.data.data.giftQty,
giftIntegral: res.data.data.payIntegral,
giftPrice: res.data.data.payMoney,
giftType: res.data.data.actType,
actTitle: res.data.data.actTitle,
wareCard: res.data.data.wareCard,
lbId: res.data.data.lbId
})
//判断是否有礼包
for (var i = 0; i < res.data.data.wareCard.length; i++) {
if (res.data.data.wareCard[i].lbType == 1) {
th.setData({
is_lb: 1
})
break;
}
}
if(res.data.data.pickup_id){
getApp().request.get("/api/weshop/pickup/get/"+os.stoid+"/"+res.data.data.pickup_id,{
success: function (res) {
if(res.data.code==0){
th.setData({pick_up:res.data.data});
}
}
});
}
} else {
getApp().my_warnning(res.data.msg, 0, th);
return false;
}
}
});
},
GetBuyGiftList: function () {
var _this2 = this;
var th = this.data;
getApp().request.get('/api/weshop/marketing/giftbag/detail/get', {
isShowLoading: true,
data: {
"storeId": a.stoid, //商家ID
"userId": d.user_id, //用户ID
"giftBagId": th.getGiftID
},
success: function success(res) {
if (res.data.code == 0) {
_this2.setData({
giftImage: th.iurl + res.data.data.lbUrl,
giftTitle: res.data.data.giftTitle,
default_color: res.data.data.bgcolor
})
if (res.data.data.giftRemark == '') {
_this2.setData({
giftRemark: '暂无详情......'
})
} else {
_this2.setData({
giftRemark: res.data.data.giftRemark.replace(/\![]()