|
@@ -0,0 +1,960 @@
|
|
|
+
|
|
|
+import {
|
|
|
+ default as productApi
|
|
|
+} from "../../api/product"
|
|
|
+
|
|
|
+const app = getApp()
|
|
|
+var utils = require('../../utils/util.js');
|
|
|
+let globalInterval = {};
|
|
|
+Page({
|
|
|
+ data: {
|
|
|
+ check_index:true,
|
|
|
+ toViewss:'',
|
|
|
+ userInfo: {},
|
|
|
+ hasUserInfo: false,
|
|
|
+ canIUse: wx.canIUse('button.open-type.getUserInfo'),
|
|
|
+ series: [],
|
|
|
+ scrollTop:"",
|
|
|
+ toView: 'series1',
|
|
|
+ toViews: '1',
|
|
|
+ showMyCar: 'false',
|
|
|
+ showSpec: true,
|
|
|
+ flavor: [
|
|
|
+ ],
|
|
|
+ plactice: [
|
|
|
+ ],
|
|
|
+ productList: [],//所有产品列表
|
|
|
+ remainDecMoney:0,
|
|
|
+ remainDecMoneyReduce:0,
|
|
|
+ remainDecMoneyHas: 0,
|
|
|
+ product_no: '',
|
|
|
+ array_flavore: [],//已选择的口味
|
|
|
+ array_plactice: [],//选择做法列表
|
|
|
+ choose_plactice: '',//选择的做法
|
|
|
+ choose_product_list: [],//已选择产品列表
|
|
|
+ chooseProduct: '',//当前选择的产品编号
|
|
|
+ chooseProductSpecPrice: '17',//有规格时的产品总价格
|
|
|
+ chooseProductPrice: '17',//有规格时产品单价
|
|
|
+ all_price: 0,//订单总价
|
|
|
+ haveChooseOrderDetail: [],//已点产品订单
|
|
|
+ haveChooseOrderDetailNum: '0',//已点产品的总数
|
|
|
+ canChooseProduct:true,
|
|
|
+ // showModal: true,
|
|
|
+ currentTab: 0,
|
|
|
+ base_img_url: app.globalData.base_img_url,
|
|
|
+
|
|
|
+ indicatorDots: true,
|
|
|
+ autoplay: true,
|
|
|
+ interval: 5000,
|
|
|
+ duration: 1000,
|
|
|
+ scroll_tops: 0,
|
|
|
+ heightTopSwiper: "35%",
|
|
|
+ topSeriesScroll: "37%",
|
|
|
+ topProductScroll: "37%",
|
|
|
+ heightSeriesScroll: "63%",
|
|
|
+ seriesBottom:"0",
|
|
|
+ menuBotDisplay:"none",
|
|
|
+ check_tying:false,
|
|
|
+ tyingOrderDetail:[],
|
|
|
+ check_mobile:false,//是否已有注册
|
|
|
+ scrollText:'',
|
|
|
+ viewStyle:{
|
|
|
+ second:0,
|
|
|
+ total:0
|
|
|
+ },
|
|
|
+ navActive:0,
|
|
|
+ loopLeft:-100,
|
|
|
+ activeTab:0,
|
|
|
+ showCart:false,
|
|
|
+ mask:true
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ onChooseTeacher:function(){
|
|
|
+ this.setData({
|
|
|
+ showModal: false,
|
|
|
+ })
|
|
|
+ },
|
|
|
+ onLoadImg: function () {
|
|
|
+ var productList = this.data.productList;
|
|
|
+ for (var i in productList) {
|
|
|
+ productList[i].img = (!productList[i].imgOrg) ? '/static/index/images/img02.jpg' : productList[i].imgOrg;
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ productList: productList,
|
|
|
+ });
|
|
|
+ },
|
|
|
+ onReady:function(){
|
|
|
+
|
|
|
+ },
|
|
|
+ onHide:function(){
|
|
|
+ console.log('清理定时器');
|
|
|
+ clearInterval(globalInterval);
|
|
|
+ },
|
|
|
+ onShow: function () {
|
|
|
+
|
|
|
+ var order_no = wx.getStorageSync('order_no');
|
|
|
+ var that = this;
|
|
|
+
|
|
|
+ var mobile = wx.getStorageSync('mobile');
|
|
|
+ var member_openid = wx.getStorageSync('member_openid');
|
|
|
+ console.log(mobile + "/////////" + member_openid);
|
|
|
+ //if (!mobile || !member_openid) {
|
|
|
+ if (!mobile) {
|
|
|
+ that.setData({
|
|
|
+ check_mobile: false
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ that.setData({
|
|
|
+ check_mobile: true
|
|
|
+ })
|
|
|
+ }
|
|
|
+ console.log(order_no)
|
|
|
+ if (order_no) {
|
|
|
+ console.log(order_no);
|
|
|
+ wx.request({
|
|
|
+ url: app.globalData.base_url + '/smdd/index/getOrder',//上线的话必须是https,没有appId的本地请求貌似不受影响
|
|
|
+ data: {
|
|
|
+ check:true,//将加购产品删除
|
|
|
+ bloc_code: app.globalData.bloc_code,
|
|
|
+ order_no: order_no
|
|
|
+ },
|
|
|
+ method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
|
|
|
+ header: app.globalData.header, // 设置请求的 header
|
|
|
+ success: function (res) {
|
|
|
+ var list = res.data.data.productList;
|
|
|
+ // var list = JSON.stringify(list);
|
|
|
+ // console.log(list);
|
|
|
+ var order_no = res.data.data.order_no;
|
|
|
+ wx.setStorageSync('order_no', order_no);
|
|
|
+ console.log(res.data.data.productList);
|
|
|
+
|
|
|
+ that.setData({
|
|
|
+ haveChooseOrderDetail: list,
|
|
|
+ haveChooseOrderDetails: res.data.data.chooseProductList,
|
|
|
+ haveChooseNoCar: res.data.data.product,
|
|
|
+ haveChooseOrderDetailNum: res.data.data.count,
|
|
|
+ all_price: res.data.data.all_price,
|
|
|
+ remainDecMoney: res.data.data.remainDecMoney.remain,
|
|
|
+ remainDecMoneyReduce: res.data.data.remainDecMoney.dec,
|
|
|
+ remainDecMoneyHas: res.data.data.remainDecMoney.has
|
|
|
+ })
|
|
|
+ if (res.data.data.count > 0){
|
|
|
+ that.setData({
|
|
|
+ menuBotDisplay: "block",
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ that.setData({
|
|
|
+ menuBotDisplay: "none",
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: function () {
|
|
|
+ // fail
|
|
|
+ },
|
|
|
+ complete: function () {
|
|
|
+ // complete
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ that.setData({
|
|
|
+ haveChooseOrderDetail: [],
|
|
|
+ haveChooseOrderDetails: [],
|
|
|
+ haveChooseNoCar:[],
|
|
|
+ haveChooseOrderDetailNum: 0
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ console.log(that.data.check_tying)
|
|
|
+ if (that.data.check_tying) {
|
|
|
+ var caont = that.data.tyingOrderDetail;
|
|
|
+ console.log(caont);
|
|
|
+ console.log("///");
|
|
|
+ if (caont.tips) {
|
|
|
+ var content = caont.tips;
|
|
|
+ } else {
|
|
|
+ var content = "亲," + caont.product_name + caont.tying_price + "元起~客官可随意挑选";
|
|
|
+ }
|
|
|
+ wx.showModal({
|
|
|
+ title: '',
|
|
|
+ content: content,
|
|
|
+ showCancel: true,
|
|
|
+ // cancelText:'cancel',
|
|
|
+ // confirmText:'sure',
|
|
|
+ success: function (e) {
|
|
|
+ if (!e.cancel) {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../../pages/package/package?product_no=' + caont.tying_product_no +'&package_id='+caont.is_package
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+
|
|
|
+ wx.showShareMenu({
|
|
|
+ withShareTicket: true
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+
|
|
|
+ productTypeList: async function(){
|
|
|
+ let self = this
|
|
|
+ let rs = await productApi.getProductTypeList(1,10000,2)
|
|
|
+ console.log(rs.list);
|
|
|
+ self.setData({
|
|
|
+ series: rs.list
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ getProductList: async function (refresh = false) {
|
|
|
+ const self = this
|
|
|
+
|
|
|
+ let prolist = await productApi.getProductList(0,1,10000,2);
|
|
|
+ self.setData({
|
|
|
+ productList:prolist.list
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+ onLoad: async function (options) {
|
|
|
+
|
|
|
+ if (options.store_id && options.table_id){
|
|
|
+ wx.removeStorageSync('order_no');
|
|
|
+ wx.setStorageSync("store_id", options.store_id);
|
|
|
+ wx.setStorageSync("table_id", options.table_id);
|
|
|
+ }
|
|
|
+
|
|
|
+ wx.showLoading({
|
|
|
+ title: 'loading',
|
|
|
+ });
|
|
|
+ var that = this;
|
|
|
+
|
|
|
+ await this.productTypeList();
|
|
|
+ await this.getProductList();
|
|
|
+ await this.initProduct();
|
|
|
+
|
|
|
+ var order_no = wx.getStorageSync('order_no');
|
|
|
+
|
|
|
+ if (order_no) {
|
|
|
+ console.log(order_no);
|
|
|
+ wx.request({
|
|
|
+ url: app.globalData.base_url + '/smdd/index/getOrder',//上线的话必须是https,没有appId的本地请求貌似不受影响
|
|
|
+ data: {
|
|
|
+ bloc_code: app.globalData.bloc_code,
|
|
|
+ order_no: order_no
|
|
|
+ },
|
|
|
+ method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
|
|
|
+ header: app.globalData.header, // 设置请求的 header
|
|
|
+ success: function (res) {
|
|
|
+ var list = res.data.data.productList;
|
|
|
+ // var list = JSON.stringify(list);
|
|
|
+ // console.log(list);
|
|
|
+ var order_no = res.data.data.order_no;
|
|
|
+ wx.setStorageSync('order_no', order_no);
|
|
|
+ //console.log(res.data.data.productList);
|
|
|
+
|
|
|
+ that.setData({
|
|
|
+ haveChooseOrderDetail: list,
|
|
|
+ haveChooseOrderDetails: res.data.data.chooseProductList,
|
|
|
+ haveChooseOrderDetailNum: res.data.data.count,
|
|
|
+ all_price: res.data.data.all_price,
|
|
|
+ remainDecMoney: res.data.data.remainDecMoney.remain,
|
|
|
+ remainDecMoneyReduce: res.data.data.remainDecMoney.dec,
|
|
|
+ remainDecMoneyHas: res.data.data.remainDecMoney.has
|
|
|
+ })
|
|
|
+ },
|
|
|
+ fail: function () {
|
|
|
+ // fail
|
|
|
+ },
|
|
|
+ complete: function () {
|
|
|
+ // complete
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ that.setData({
|
|
|
+ haveChooseOrderDetail: [],
|
|
|
+ haveChooseOrderDetails: [],
|
|
|
+ haveChooseOrderDetailNum: 0
|
|
|
+ })
|
|
|
+ }
|
|
|
+ that.setData({
|
|
|
+ check_index:false
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getUserInfo: function (e) {
|
|
|
+ console.log(e)
|
|
|
+ app.globalData.userInfo = e.detail.userInfo
|
|
|
+ this.setData({
|
|
|
+ userInfo: e.detail.userInfo,
|
|
|
+ hasUserInfo: true
|
|
|
+ })
|
|
|
+ },
|
|
|
+ loop:function(){
|
|
|
+ let millisecond = this.data.viewStyle.second*1000;
|
|
|
+ let total = this.data.viewStyle.total;
|
|
|
+ let speed = 1000;
|
|
|
+ let _self = this;
|
|
|
+
|
|
|
+ globalInterval = setInterval(function(){
|
|
|
+ let iv = total / (millisecond / speed);
|
|
|
+ _self.data.loopLeft -= iv;
|
|
|
+ if (Math.abs(_self.data.loopLeft) >= total){
|
|
|
+ _self.data.loopLeft = 300;
|
|
|
+ }
|
|
|
+
|
|
|
+ _self.setData({
|
|
|
+ loopLeft: _self.data.loopLeft
|
|
|
+ });
|
|
|
+ }, speed);
|
|
|
+ },
|
|
|
+ showMyCarClick: function (e) {
|
|
|
+ var istrue = e.target.dataset.istrue;
|
|
|
+ console.log(istrue);
|
|
|
+ this.setData({
|
|
|
+ showMyCar: !istrue,
|
|
|
+ showSpec: true,
|
|
|
+ })
|
|
|
+
|
|
|
+ },
|
|
|
+ goMember: function (e) {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/pages/newIndexs/newIndexs',
|
|
|
+ // url:'/pages/memberIndex/memberIndex'
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ showSpecClick: function (e) {
|
|
|
+ var istrue = e.target.dataset.showspec;
|
|
|
+ var plactice = this.data.choose_plactice;
|
|
|
+ var flavor = this.data.flavor;
|
|
|
+
|
|
|
+ if (istrue == true) {
|
|
|
+ var price = e.target.dataset.price
|
|
|
+ var product_no = e.target.dataset.no;
|
|
|
+ var that = this;
|
|
|
+ wx.request({
|
|
|
+ url: app.globalData.base_url + '/smdd/index/getAddProduct',//上线的话必须是https,没有appId的本地请求貌似不受影响
|
|
|
+ data: {
|
|
|
+ bloc_code: app.globalData.bloc_code,
|
|
|
+ product_no: product_no,//大华店
|
|
|
+ },
|
|
|
+ method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
|
|
|
+ header: app.globalData.header, // 设置请求的 header
|
|
|
+ success: function (res) {
|
|
|
+ console.log(res.data.data)
|
|
|
+ console.log(res.data.code);
|
|
|
+ if (res.data.code == '200') {
|
|
|
+ if (res.data.data) {
|
|
|
+ var flavor = [];//口味
|
|
|
+ var plactice = [];//做法
|
|
|
+ var add_arr = res.data.data;
|
|
|
+ for (let i = 0; i < add_arr.length; i++) {
|
|
|
+ console.log(add_arr[i].img);
|
|
|
+ if (add_arr[i]['type'] == 1) {//口味
|
|
|
+ flavor[i] = add_arr[i];
|
|
|
+ flavor[i]['is_select'] = "false";
|
|
|
+ } else if (add_arr[i]['type'] == 2) {
|
|
|
+ plactice[i] = add_arr[i];
|
|
|
+ plactice[i]['is_select'] = "false";
|
|
|
+ }
|
|
|
+ }
|
|
|
+ that.setData({
|
|
|
+ flavor: flavor,
|
|
|
+ plactice: plactice,
|
|
|
+ chooseProductPrice: price,//有规格时产品单价
|
|
|
+ chooseProductSpecPrice: price,//有规格时的产品总价格
|
|
|
+ showSpec: !istrue,
|
|
|
+ chooseProduct: product_no,
|
|
|
+ choose_plactice: '',
|
|
|
+ array_plactice: []
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ this.setData({
|
|
|
+ showSpec: !istrue,
|
|
|
+ })
|
|
|
+ var product_no = e.target.dataset.no;
|
|
|
+ var arr = this.getChooseAdd();
|
|
|
+ console.log(arr);
|
|
|
+ if (product_no > 0) {
|
|
|
+ // 不可以重复下单
|
|
|
+ this.setData({
|
|
|
+ canChooseProduct:false
|
|
|
+ })
|
|
|
+ this.chooseProduct(product_no, arr);
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ },
|
|
|
+ tap: function (e) {
|
|
|
+ var id = e.currentTarget.dataset.id;
|
|
|
+ var index = e.currentTarget.dataset.index;
|
|
|
+ this.setData({
|
|
|
+ toView: id,
|
|
|
+ navActive: index
|
|
|
+ });
|
|
|
+ },
|
|
|
+ clickScroll: function (e) {
|
|
|
+ var id = e.currentTarget.dataset.id
|
|
|
+ var action = e.currentTarget.dataset.action
|
|
|
+ console.log(e);
|
|
|
+ this.setData({
|
|
|
+ toView: id,
|
|
|
+ toViews: action,
|
|
|
+ seriesClickToView:id
|
|
|
+ })
|
|
|
+ },
|
|
|
+ scroll: function (e) {
|
|
|
+ var scrollTop = e.detail.scrollTop;
|
|
|
+ var scrollArr = this.data.hightArr;
|
|
|
+
|
|
|
+ var active = "";
|
|
|
+ for (var i = 0; i < scrollArr.length; i++) {
|
|
|
+ if (scrollTop >= 0 && scrollTop < scrollArr[1] - scrollArr[0]-50) {
|
|
|
+ active = 0;
|
|
|
+
|
|
|
+ } else if (scrollTop >= scrollArr[i] - scrollArr[0]-50 && scrollTop < scrollArr[i + 1] - scrollArr[0]-50) {
|
|
|
+ active = i;
|
|
|
+
|
|
|
+ } else if (scrollTop >= scrollArr[scrollArr.length - 1] - scrollArr[0]-50) {
|
|
|
+ active = scrollArr.length - 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log(active);
|
|
|
+ this.setData({
|
|
|
+ navActive: active
|
|
|
+ })
|
|
|
+ },
|
|
|
+ scrolls:function(e){
|
|
|
+ console.log(e);
|
|
|
+ },
|
|
|
+ onPageScroll: function (e) {
|
|
|
+ },
|
|
|
+ onPullDownRefresh: function (e) {
|
|
|
+ cosole.log(e)
|
|
|
+ },
|
|
|
+ leftMenu: function (rightId) {
|
|
|
+ },
|
|
|
+ flavorClick: function (e) {
|
|
|
+ console.log(e);
|
|
|
+ var arrs = this.data.array_flavore;
|
|
|
+ console.log(arrs);
|
|
|
+ var ids = e.target.dataset.id;
|
|
|
+ var chec = 2;
|
|
|
+ if (arrs) {
|
|
|
+ for (let i = 0; i < arrs.length; i++) {
|
|
|
+ console.log(arrs[i]);
|
|
|
+ if (arrs[i] == ids) {
|
|
|
+ arrs.splice(i, 1)
|
|
|
+ chec = 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (chec == 2) {
|
|
|
+ arrs.push(ids);
|
|
|
+ }
|
|
|
+ if (arrs) {
|
|
|
+ var flavore_arr = [];
|
|
|
+ var flavore = this.data.flavor;
|
|
|
+ console.log(flavore);
|
|
|
+ for (let i = 0; i < flavore.length; i++) {
|
|
|
+ // console.log(1111);
|
|
|
+ var check_flo = 1;
|
|
|
+ for (let j = 0; j < arrs.length; j++) {
|
|
|
+ if (arrs[j] == flavore[i]["add_id"]) {
|
|
|
+ check_flo = 2;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (check_flo == 1) {
|
|
|
+ flavore[i]["is_select"] = 'false';
|
|
|
+ } else {
|
|
|
+ flavore[i]["is_select"] = 'true';
|
|
|
+ }
|
|
|
+ flavore_arr[i] = flavore[i];
|
|
|
+ }
|
|
|
+ this.setData({
|
|
|
+ flavor: flavore_arr,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ console.log(this.data.array_flavore);
|
|
|
+ this.colmProudtcPrice();
|
|
|
+ },
|
|
|
+ placticeClick: function (e) {
|
|
|
+ console.log(e);
|
|
|
+ var ids = e.target.dataset.id;
|
|
|
+ e.target.dataset.name = "check";
|
|
|
+ this.setData({
|
|
|
+ array_plactice: ["ids"],
|
|
|
+ choose_plactice: ids
|
|
|
+ })
|
|
|
+ this.colmProudtcPrice();
|
|
|
+ },
|
|
|
+ colmProudtcPrice: function () {//计算有规格的产品的价格
|
|
|
+ var spec_price = 0;//选择规则的价格
|
|
|
+ var chooseProductPrice = this.data.chooseProductPrice;//产品单价
|
|
|
+ var choose_plactice = this.data.choose_plactice;//选择的做法no【单选】
|
|
|
+ var flavore = this.data.flavor;//做法数组
|
|
|
+ var plactice = this.data.plactice;//口味数组
|
|
|
+ console.log(choose_plactice);
|
|
|
+ console.log(plactice);
|
|
|
+ if (flavore) {
|
|
|
+ for (let i = 0; i < flavore.length; i++) {
|
|
|
+ if (flavore[i]['is_select'] == "true") {
|
|
|
+ spec_price = spec_price * 1 + flavore[i]['price'] * 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (plactice && choose_plactice) {
|
|
|
+ for (let j = 0; j < plactice.length; j++) {
|
|
|
+ if (plactice[j]['add_id'] == choose_plactice) {
|
|
|
+ spec_price = spec_price * 1 + plactice[j]['price'] * 1;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ console.log(spec_price + "///" + chooseProductPrice);
|
|
|
+ this.setData({
|
|
|
+ chooseProductSpecPrice: spec_price * 1 + chooseProductPrice * 1
|
|
|
+ })
|
|
|
+ },
|
|
|
+ getChooseAdd: function () {
|
|
|
+ var flavore = this.data.flavor;//做法数组
|
|
|
+ var choose_plactice = this.data.choose_plactice;//选择的做法no【单选】
|
|
|
+ var plactice = this.data.plactice;//口味数组
|
|
|
+ console.log(choose_plactice);
|
|
|
+ console.log(plactice);
|
|
|
+ var arr = [];
|
|
|
+ var j = 0;
|
|
|
+ if (flavore) {
|
|
|
+ for (let i = 0; i < flavore.length; i++) {
|
|
|
+ if (flavore[i]['is_select'] == "true") {
|
|
|
+ arr[j] = flavore[i]['add_id'];
|
|
|
+ j++;
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (choose_plactice) {
|
|
|
+ arr.push(choose_plactice);
|
|
|
+ }
|
|
|
+ return arr;
|
|
|
+ },
|
|
|
+ productDetail:function(e){
|
|
|
+ var product_no = e.target.dataset.no;
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../indexbaixiong/productDetail/productDetail?product_no=' + product_no
|
|
|
+ })
|
|
|
+ },
|
|
|
+ packages: function (e) {
|
|
|
+ var package_id = e.target.dataset.id;
|
|
|
+ var product_no = e.target.dataset.no;
|
|
|
+ var haveChooseProduct = this.data.haveChooseOrderDetail;
|
|
|
+ var choose_num = 0;
|
|
|
+ var that = this;
|
|
|
+ if (package_id > 0) {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../indexbaixiong/package/package?package_id=' + package_id + '&product_no=' + product_no
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ // 不可以重复下单
|
|
|
+ this.setData({
|
|
|
+ canChooseProduct:false
|
|
|
+ })
|
|
|
+ this.chooseProduct(product_no, '');
|
|
|
+ }
|
|
|
+
|
|
|
+ },
|
|
|
+ chooseProduct: function (product_no, add) {
|
|
|
+
|
|
|
+ var order_no = wx.getStorageSync('order_no');
|
|
|
+ var tableInfo = wx.getStorageSync('tableInfo');
|
|
|
+ var add = JSON.stringify(add);
|
|
|
+ wx.showLoading({
|
|
|
+ title: '加入购物车',
|
|
|
+ mask: true
|
|
|
+ });
|
|
|
+ console.log('<-----------here----------->');
|
|
|
+ var haveChooseProduct = this.data.haveChooseOrderDetail;
|
|
|
+ var that = this;
|
|
|
+ wx.request({
|
|
|
+ url: app.globalData.base_url + '/smdd/index/OrderDetail',//上线的话必须是https,没有appId的本地请求貌似不受影响
|
|
|
+ data: {
|
|
|
+ bloc_code: app.globalData.bloc_code,
|
|
|
+ product_no: product_no,
|
|
|
+ add_array: add,
|
|
|
+ order_no: order_no,
|
|
|
+ tableInfo: tableInfo,
|
|
|
+ store_id: wx.getStorageSync('store_id'),
|
|
|
+ mobile: wx.getStorageSync('mobile')
|
|
|
+ },
|
|
|
+ method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
|
|
|
+ header: app.globalData.header, // 设置请求的 header
|
|
|
+ success: function (res) {
|
|
|
+ wx.hideLoading();
|
|
|
+ console.log(res.data.data);
|
|
|
+ // console.log(res.data.code);
|
|
|
+ if (res.data.code == '200') {
|
|
|
+ var list = res.data.data.productList;
|
|
|
+ var order_no = res.data.data.order_no;
|
|
|
+ wx.setStorageSync('order_no', order_no);
|
|
|
+ console.log(res.data.data.productList);
|
|
|
+ that.setData({
|
|
|
+ haveChooseOrderDetails: res.data.data.chooseProductList,
|
|
|
+ haveChooseNoCar: res.data.data.product,
|
|
|
+ haveChooseOrderDetail: list,
|
|
|
+ haveChooseOrderDetailNum: res.data.data.count,
|
|
|
+ menuBotDisplay:"block",
|
|
|
+ all_price: res.data.data.all_price,
|
|
|
+ remainDecMoney: res.data.data.remainDecMoney.remain,
|
|
|
+ remainDecMoneyReduce: res.data.data.remainDecMoney.dec,
|
|
|
+ remainDecMoneyHas: res.data.data.remainDecMoney.has
|
|
|
+ })
|
|
|
+
|
|
|
+ if (res.data.data.check_tying == true){
|
|
|
+ // that.setData({
|
|
|
+ // tyingProduct_no: res.data.data.tyingProductList.product_no,
|
|
|
+ // tyingSeries_id: res.data.data.tyingProductList.series_id
|
|
|
+ // })
|
|
|
+ if (res.data.data.tyingProductList.tips) {
|
|
|
+ var content = res.data.data.tyingProductList.tips;
|
|
|
+ } else {
|
|
|
+ var content = "亲," + res.data.data.tyingProductList.product_name + res.data.data.tyingProductList.tying_price + "元起~客官可随意挑选";
|
|
|
+ }
|
|
|
+ wx.showModal({
|
|
|
+ title: '',
|
|
|
+ content: content,
|
|
|
+ showCancel:true,
|
|
|
+ // cancelText:'cancel',
|
|
|
+ // confirmText:'sure',
|
|
|
+ success:function(e){
|
|
|
+ if(!e.cancel){
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../../pages/productDetail/productDetail?product_no=' + res.data.data.tyingProductList.tying_product_no + '&check=1&tying_price=' + res.data.data.tyingProductList.tying_price
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }else{
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: res.data.msg,
|
|
|
+ showCancel:false
|
|
|
+ })
|
|
|
+ }
|
|
|
+ that.setData({
|
|
|
+ canChooseProduct:true
|
|
|
+ })
|
|
|
+ },
|
|
|
+ })
|
|
|
+ },
|
|
|
+ deleteProduct: function (e) {
|
|
|
+ wx.showLoading({
|
|
|
+ title: 'loading',
|
|
|
+ mask: true
|
|
|
+ })
|
|
|
+ var no = e.target.dataset.no;
|
|
|
+ var id = e.target.dataset.id;
|
|
|
+ var order_no = wx.getStorageSync('order_no');
|
|
|
+ var that = this;
|
|
|
+ console.log(no);
|
|
|
+ wx.request({
|
|
|
+ url: app.globalData.base_url + '/smdd/index/deleteProduct',//上线的话必须是https,没有appId的本地请求貌似不受影响
|
|
|
+ data: {
|
|
|
+ bloc_code: app.globalData.bloc_code,
|
|
|
+ product_no: no,//
|
|
|
+ order_no: order_no,
|
|
|
+ id: id
|
|
|
+ },
|
|
|
+ method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
|
|
|
+ header: app.globalData.header, // 设置请求的 header
|
|
|
+ success: function (res) {
|
|
|
+ console.log(res);
|
|
|
+ if (res.data.code == '200') {
|
|
|
+ var list = res.data.data.productList;
|
|
|
+ that.setData({
|
|
|
+ haveChooseOrderDetail: list,
|
|
|
+ haveChooseOrderDetails: res.data.data.chooseProductList,
|
|
|
+ haveChooseNoCar: res.data.data.product,
|
|
|
+ haveChooseOrderDetailNum: res.data.data.count,
|
|
|
+ all_price: res.data.data.all_price,
|
|
|
+ remainDecMoney: res.data.data.remainDecMoney.remain,
|
|
|
+ remainDecMoneyReduce: res.data.data.remainDecMoney.dec,
|
|
|
+ remainDecMoneyHas: res.data.data.remainDecMoney.has
|
|
|
+ })
|
|
|
+ if (res.data.data.count > 0) {
|
|
|
+ that.setData({
|
|
|
+ menuBotDisplay: "block",
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ that.setData({
|
|
|
+ menuBotDisplay: "none",
|
|
|
+ })
|
|
|
+ }
|
|
|
+ if (res.data.data.first_check_tying == true){
|
|
|
+ wx.showModal({
|
|
|
+ title: '',
|
|
|
+ content: res.data.data.first_check_tying_name+"将被恢复原价",
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ wx.hideLoading();
|
|
|
+ },
|
|
|
+ start_order: function (e) {
|
|
|
+ // wx.requestSubscribeMessage({
|
|
|
+ // tmplIds: ['JpCFOwqltafef9abxKme6LFXHA-i9lKH2Z7IbngLKu0'],
|
|
|
+ // success(res) {
|
|
|
+ // console.log(res);
|
|
|
+ // console.log("111");
|
|
|
+ // },
|
|
|
+ // complete(ress) {
|
|
|
+ // console.log(ress)
|
|
|
+ // console.log("222");
|
|
|
+ // }
|
|
|
+ // })
|
|
|
+ var order_no = wx.getStorageSync('order_no');
|
|
|
+if(this.data.haveChooseOrderDetails.length>0){
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '/pages/order/order'
|
|
|
+ })
|
|
|
+}else{
|
|
|
+ wx.showModal({
|
|
|
+ content: '请选择产品',
|
|
|
+ })
|
|
|
+}
|
|
|
+ // if (order_no) {
|
|
|
+ // }
|
|
|
+ },
|
|
|
+ order: function () {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../records/records'
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ clearAll: function () {
|
|
|
+ var order_no = wx.getStorageSync('order_no');
|
|
|
+ var that = this;
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: "确定清除吗",
|
|
|
+ success: function (res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ wx.showLoading({
|
|
|
+ title: 'loading',
|
|
|
+ mask: true
|
|
|
+ })
|
|
|
+ wx.request({
|
|
|
+ url: app.globalData.base_url + '/smdd/index/clearAll',//上线的话必须是https,没有appId的本地请求貌似不受影响
|
|
|
+ data: {
|
|
|
+ bloc_code: app.globalData.bloc_code,
|
|
|
+ order_no: order_no
|
|
|
+ },
|
|
|
+ method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
|
|
|
+ header: app.globalData.header, // 设置请求的 header
|
|
|
+ success: function (res) {
|
|
|
+ if (res.data.code == '200') {
|
|
|
+ wx.setStorageSync('order_no', '');
|
|
|
+ that.setData({
|
|
|
+ haveChooseOrderDetail: [],
|
|
|
+ haveChooseOrderDetails: [],
|
|
|
+ haveChooseNoCar:[],
|
|
|
+ haveChooseOrderDetailNum: 0,
|
|
|
+ all_price: 0
|
|
|
+ })
|
|
|
+ }
|
|
|
+ wx.hideLoading()
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ noStartOrder: function () {
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: "请选择产品",
|
|
|
+ showCancel: false,
|
|
|
+ success: function (res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ console.log('用户点击确定')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+ clickTuiImg:function(e){
|
|
|
+ console.log(e);
|
|
|
+ },
|
|
|
+ clickImg: function (e) {
|
|
|
+ var no = e.target.dataset.url;
|
|
|
+ if(no){
|
|
|
+ this.setData({
|
|
|
+ toView: "series" + no,
|
|
|
+ toViews: no,
|
|
|
+ })
|
|
|
+ }
|
|
|
+ console.log(e);
|
|
|
+ },
|
|
|
+
|
|
|
+ getPhoneNumber:function(e){
|
|
|
+ var store_id = this.data.store_id;
|
|
|
+ this.checkLogin(e,store_id);
|
|
|
+ // console.log(e.detail.encryptedData);
|
|
|
+ },
|
|
|
+ checkLogin:function(e,store_id){
|
|
|
+ var that=this;
|
|
|
+ wx.login({
|
|
|
+ success: function (res) {
|
|
|
+ var code = res.code;
|
|
|
+ console.log(res);
|
|
|
+ //console.log(111);
|
|
|
+ if(code){
|
|
|
+ wx.request({
|
|
|
+ url: app.globalData.base_url + '/smdd/index/getOpenid',//上线的话必须是https,没有appId的本地请求貌似不受影响
|
|
|
+ data: {
|
|
|
+ code: res.code,
|
|
|
+ encryptedData: e.detail.encryptedData,
|
|
|
+ iv: e.detail.iv,
|
|
|
+ types: "smdd",
|
|
|
+ "bloc_code": app.globalData.bloc_code,
|
|
|
+ api_code: app.globalData.bloc_code,
|
|
|
+ },
|
|
|
+ method: 'POST', // OPTIONS, GET, HEAD, POST, PUT, DELETE, TRACE, CONNECT
|
|
|
+ header: app.globalData.header, // 设置请求的 header
|
|
|
+ success: function (res) {
|
|
|
+ console.log(res);
|
|
|
+ if (res.data.code == 400) {
|
|
|
+ wx.showModal({
|
|
|
+ title: '提示',
|
|
|
+ content: res.data.msg,
|
|
|
+ success: function (res) {
|
|
|
+ if (res.confirm) {
|
|
|
+ console.log('用户点击确定')
|
|
|
+ }
|
|
|
+ }
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ wx.setStorageSync("mobile", res.data.data.mobile);
|
|
|
+ wx.setStorageSync("openid", res.data.data.openid);
|
|
|
+ that.setData({
|
|
|
+ check_mobile: true
|
|
|
+ })
|
|
|
+
|
|
|
+ //console.log(res.data.data.openid);
|
|
|
+ // if (!store_id) {
|
|
|
+ /*
|
|
|
+ wx.redirectTo({
|
|
|
+ url: '../getIntoUser/getIntoUser',
|
|
|
+ })
|
|
|
+ */
|
|
|
+
|
|
|
+ // } else {
|
|
|
+ // wx.redirectTo({
|
|
|
+ // url: '../index/index',
|
|
|
+ // })
|
|
|
+ // }
|
|
|
+ }
|
|
|
+ },
|
|
|
+ fail: function () {
|
|
|
+ // fail
|
|
|
+ },
|
|
|
+ complete: function () {
|
|
|
+ // complete
|
|
|
+ }
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ var check_num = that.check_num * 1+1*1;
|
|
|
+ if(check_num>2){
|
|
|
+ wx.showModal({
|
|
|
+ title: '',
|
|
|
+ content: '授权失败,请退出重试',
|
|
|
+ })
|
|
|
+ }else{
|
|
|
+ that.setData({
|
|
|
+ check_num: check_num,
|
|
|
+ });
|
|
|
+ that.getPhoneNumber(e);
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+ })
|
|
|
+ },
|
|
|
+
|
|
|
+ getMobile: function () {
|
|
|
+ var mobile = wx.getStorageSync('mobile');
|
|
|
+ wx.setStorageSync('check_go_where', 'index');
|
|
|
+ if (!mobile) {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../getInto/getInto',
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../getIntoUser/getIntoUser',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+ getMobileX: function () {
|
|
|
+ var mobile = wx.getStorageSync('mobile');
|
|
|
+ //点击取消,默认隐藏弹框
|
|
|
+ wx.setStorageSync('check_go_where', 'index');
|
|
|
+ if (!mobile) {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../getInto/getInto',
|
|
|
+ })
|
|
|
+ } else {
|
|
|
+ wx.navigateTo({
|
|
|
+ url: '../getIntoUser/getIntoUser',
|
|
|
+ })
|
|
|
+ }
|
|
|
+ },
|
|
|
+
|
|
|
+ handleTabClick: function (e) {
|
|
|
+ let index = e.currentTarget.dataset.index;
|
|
|
+ this.activeTab(index);
|
|
|
+ this.setData({ activeTab: index });
|
|
|
+ },
|
|
|
+ handleSwiperChange: function (e) {
|
|
|
+ var index = e.detail.current;
|
|
|
+ this.activeTab(index);
|
|
|
+ this.setData({ activeTab: index });
|
|
|
+ },
|
|
|
+ activeTab: function (_activeTab) {
|
|
|
+ var len = this.data.series.length;
|
|
|
+ if (len === 0) return;
|
|
|
+ var currentView = _activeTab - 1;
|
|
|
+ if (currentView < 0) currentView = 0;
|
|
|
+ if (currentView > len - 1) currentView = len - 1;
|
|
|
+ this.setData({ currentView: currentView });
|
|
|
+ },
|
|
|
+
|
|
|
+ initProduct: function(){
|
|
|
+ let series = this.data.series;
|
|
|
+ let productList = this.data.productList;
|
|
|
+ let currentProductList = [];
|
|
|
+ series.forEach((item,index) => {
|
|
|
+ currentProductList[index] = [];
|
|
|
+ let i = 0;
|
|
|
+ productList.forEach((element,pindex) => {
|
|
|
+
|
|
|
+ if (element.productTypeId == item.id){
|
|
|
+ currentProductList[index][i] = element;
|
|
|
+ i++;
|
|
|
+ }
|
|
|
+ });
|
|
|
+ });
|
|
|
+ this.setData({
|
|
|
+ currentProductList:currentProductList
|
|
|
+ })
|
|
|
+ },
|
|
|
+ openCartDialog: function(e){
|
|
|
+ let type = e.currentTarget.dataset.type;
|
|
|
+ if (type === 'open'){
|
|
|
+ this.setData({showCart:true})
|
|
|
+ }else{
|
|
|
+ this.setData({showCart:false})
|
|
|
+ }
|
|
|
+ }
|
|
|
+})
|