Commit 06f716a8600a8f8c291d9952b05e259fc72f27ed

Authored by season
1 parent 47bd743f

删除app.js

Showing 1 changed file with 0 additions and 421 deletions
app.js deleted
1   -var t = require("setting.js"), o = require("./utils/auth.js"), a = require("./utils/request.js"), e = require("./utils/common.js"), ut = require("./utils/util.js");
2   -var os=t;
3   -var regeneratorRuntime = require('./utils/runtime.js');
4   -var api = require("./api/api.js")
5   -
6   -//公共方法和变量
7   -App({
8   - globalData: {
9   - setting: t,
10   - wechatUser: null,
11   - userInfo: null,
12   - config: null, //门店参数
13   - config2: null, //门店配置
14   - code: null,
15   - heigth:0,
16   -<<<<<<< HEAD
17   - user_id: null,// 4379287,// null,// 5682068,
18   -=======
19   - user_id: null,// 4379287,// null,// 5682068,
20   ->>>>>>> 05be2e3b599969d92db349a2724ac4567ebc2987
21   - buy_now:null,
22   - picklist:null, //门店列表
23   - wuliuprice: null, //物流价格表
24   - wuliu: null, //物流公司
25   - baddr:null,
26   - mobile: null, //记录手机
27   - getu:null, //记录会员信息
28   - sessionKey: null,//记录会员信息
29   - openid: null, //记录会员信息
30   -
31   - to_group:null, //参团传递的数据
32   - wxapp_buy_obj:null, //微信小程序购买的Object
33   - pk_store:null, //选择的门店
34   -
35   - },
36   - auth: o,
37   - request: a,
38   - onLaunch: function() {
39   - this.initExt();
40   - var t = this.globalData.setting;
41   - t.resourceUrl = t.url + "/template/mobile/rainbow";
42   - var clientWidth = wx.getSystemInfoSync().windowWidth;
43   - var rpxR = 750 / clientWidth;
44   - var calc = wx.getSystemInfoSync().windowHeight * rpxR;
45   - this.globalData.heigth=calc;
46   -
47   - var app=this;
48   - if(!app.globalData.userInfo){
49   - var user = wx.getStorageSync("userinfo");
50   - if (user && user.user_id){
51   - app.globalData.userInfo=wx.getStorageSync("userinfo");
52   - app.globalData.user_id= app.globalData.userInfo.user_id;
53   - }
54   - }
55   - },
56   -
57   - //---初始化第三方----
58   - initExt: function() {
59   - var tt=t;
60   - console.log("initExt");
61   - console.log(11);
62   - var t = wx.getExtConfigSync(), o = this.globalData.setting;
63   - console.log(t);
64   - t.appName ? (o.appName = t.appName, o.stoid = t.stoid) : tt=1;
65   -
66   -
67   - },
68   -
69   - //首页的第一次登录
70   - getUserFir(t){
71   - var s = this;
72   - if (o.isAuth()) "function" == typeof t && t(s.globalData.userInfo, s.globalData.wechatUser); else {
73   - if (!o.isAuth()) return o.wxLogin_fir(t);
74   - if (null == s.globalData.userInfo) {
75   - return o.wxLogin_fir(t);
76   - }
77   - }
78   - },
79   -
80   - getUserInfo: function(t, n, i) {
81   - var s = this;
82   - if (o.isAuth()) "function" == typeof t && t(s.globalData.userInfo, s.globalData.wechatUser); else {
83   - if (!o.isAuth()) return o.auth(t);
84   - if (null == s.globalData.userInfo){
85   - return o.auth(t);
86   - }
87   - /*---
88   - a.get("/api/user/userInfo", {
89   - isShowLoading: void 0 === i || i,
90   - success: function(o) {
91   - s.globalData.userInfo = o.data.result, s.globalData.userInfo.head_pic = e.getFullUrl(s.globalData.userInfo.head_pic),
92   - "function" == typeof t && t(s.globalData.userInfo, s.globalData.wechatUser);
93   - }
94   - });--*/
95   - }
96   - },
97   - //----------------获取配置参数--------------------
98   - getConfig: function(t, o) {
99   - var e = this; if(this.globalData.config==undefined) this.globalData.config=null;
100   - this.globalData.config ? "function" == typeof t && t(this.globalData.config) : e.request.get("/api/weshop/store/get/" + e.globalData.setting.stoid, {
101   - success: function(o) {
102   - console.log('getConfig');
103   - if(o.data.code==0){
104   - e.globalData.config = o.data.data, "function" == typeof t && t(e.globalData.config);
105   - }
106   - }
107   - });
108   - },
109   -
110   - //----------------获取配置参数--------------------
111   - getConfig2: function (t, o) {
112   - var e = this;
113   - this.globalData.config2 && !o ?
114   - "function" == typeof t && t(this.globalData.config2) : a.get("/api/weshop/storeconfig/get/" + e.globalData.setting.stoid, {
115   - success: function (o) {
116   - console.log('getConfig2');
117   - if (o.data.code == 0) {
118   - e.globalData.config2 = o.data.data, "function" == typeof t && t(e.globalData.config2);
119   - }
120   - }
121   - });
122   - },
123   -
124   - //----------------获取商家开启的物流--------------------
125   - getwuliu: function (t, o){
126   - var th = this, st = this.globalData.setting;
127   - this.globalData.wuliu && !o ?
128   - "function" == typeof t && t(this.globalData.wuliu) : a.get("/api/weshop/storeshipping/list", {
129   - data: { store_id: st.stoid, status: 1, pageSize:600 },
130   - success: function (o) {
131   - console.log('getwuliu');
132   - console.log(o);
133   - if (o.data.code == 0) {
134   - var arr = o.data.data.pageData;
135   - console.log(arr);
136   - arr.forEach(function(item,index){
137   - arr[index].code = item.shipping_code; arr[index].name = item.shipping_name;
138   - })
139   - th.globalData.wuliu = arr, "function" == typeof t && t(arr);
140   - }
141   - }
142   - });
143   - },
144   -
145   - //----------------获取物流价格表--------------------
146   - getwuliuprice: function (t, o) {
147   - var e = this,th=e, st = this.globalData.setting;
148   - this.globalData.wuliuprice && !o ?
149   - "function" == typeof t && t(this.globalData.wuliuprice) : a.get("/api/weshop/shippingarea/list",{
150   - data: { store_id: st.stoid,pageSize: 600 },
151   - success: function (o) {
152   - console.log('getwuliuprice');
153   - console.log(o);
154   - if (o.data.code == 0) {
155   - var arr=o.data.data.pageData;
156   - console.log(arr);
157   - if (arr.length>0){
158   - for (var i = 0; i < arr.length;i++){
159   - arr[i].code = arr[i].shipping_code;
160   - if (arr[i].json_config != "" && arr[i].json_config != undefined && arr[i].json_config != null )
161   - arr[i].config = JSON.parse(arr[i].json_config);
162   - }
163   - }
164   - th.globalData.wuliuprice = o.data.data, "function" == typeof t && t(e.globalData.wuliuprice);
165   - }
166   - }
167   - });
168   - },
169   - //----------------设置立即购买数组--------------------
170   - set_b_now: function (d) { this.globalData.buy_now=d;},
171   - get_b_now: function () {return this.globalData.buy_now},
172   -
173   - getPrevPageData: function(t) {
174   - void 0 === t && (t = 1);
175   - var o = getCurrentPages();
176   - return o[o.length - t - 1].data;
177   - },
178   - showLoading: function(t, o) {
179   - void 0 === o && (o = 1500), wx.showToast({
180   - title: "加载中",
181   - icon: "loading",
182   - duration: o,
183   - mask: !0,
184   - complete: function() {
185   - "function" == typeof t && setTimeout(t, o);
186   - }
187   - });
188   - },
189   - showSuccess: function(t, o, a) {
190   - void 0 === a && (a = 1e3), wx.showToast({
191   - title: t,
192   - icon: "success",
193   - duration: a,
194   - mask: !0,
195   - complete: function() {
196   - "function" == typeof o && setTimeout(o, a);
197   - }
198   - });
199   - },
200   - showWarning: function(t, o, a, e) {
201   - //var imghost=this.globalData.setting.imghost;
202   - !a && (a = 1500), void 0 === e && (e = !0), wx.showToast({
203   - title: t,
204   - mask: e,
205   - duration: a,
206   - image:"/images/gt.png",
207   - complete: function() {
208   - "function" == typeof o && setTimeout(o, a);
209   - }
210   - });
211   - },
212   -
213   - confirmBox: function(t, o) {
214   - wx.showModal({
215   - title: t,
216   - showCancel: !1,
217   - complete: function() {
218   - "function" == typeof o && o();
219   - }
220   - });
221   - },
222   -
223   - //----------获取所有的门店------------
224   - get_allsto(func){
225   - var th=this;
226   - if (this.globalData.picklist!=null){
227   - "function" == typeof func && func(th.globalData.picklist);
228   - }else{
229   - th.request.get("/api/weshop/pickup/page", {
230   - data: { store_id: th.globalData.setting.stoid, pageSize: 600 },
231   - success: function (da) {
232   - //设置门店
233   - //th.setData({ allsto: da.data.data.pageData });
234   - th.globalData.picklist = da.data.data.pageData;
235   - "function" == typeof func && func(th.globalData.picklist);
236   - }
237   - })
238   - }
239   - },
240   -
241   - //同步化,在调用的时候要await
242   - async get_isbuy() {
243   -
244   - var th=this;
245   - await api.check_isbuy({ store_id: t.stoid, type: 5 }).then(res=>{
246   - var o=res;
247   - if (o.data.code == 0) {
248   - var ob = { isout: 0, isbuy: 1 };
249   - var arr = o.data.data.pageData;
250   - var isbuy = 0;
251   - //----如果数组不为空----
252   - if (arr.length > 0) {
253   - arr.forEach(function (val, ind) {
254   - if (val.is_sy == 0 && val.type == 5) {
255   - isbuy = 1;
256   - var now = ut.gettimestamp();
257   - if (now > val.end_time) ob.isout = 1;
258   - return false;
259   - }
260   - })
261   - }
262   - ob.isbuy = isbuy;
263   - th.globalData.wxapp_buy_obj=ob;
264   - }
265   - })
266   - },
267   -
268   - //--同步化,在调用的时候要await,获取商家config--
269   - async getConfig_ays(){
270   - if(this.globalData.config!=null) return false;
271   - var th=this;
272   - await api.get_config(this.globalData.setting.stoid).then(res=>{
273   - var o=res;
274   - if(o.data.code==0){
275   - th.globalData.config = o.data.data;
276   - }
277   - })
278   - },
279   -
280   - //----智能跳转,判断 非tabBar,tabBar页面的跳转----
281   - goto:function (url) {
282   - var arr_tabbar=["/pages/index/index/index","/pages/goods/categoryList/categoryList",
283   - "/pages/goods/categoryList/categoryList?type=2",
284   - "/pages/goods/categoryList/categoryList?type=1",
285   - "/pages/cart/cart/cart","/pages/user/index/index"];
286   - if(arr_tabbar.indexOf(url)!=-1){
287   - if(url.indexOf("categoryList?type=1")!=-1) this.globalData.cat_type=1;
288   - if(url.indexOf("categoryList?type=2")!=-1) this.globalData.cat_type=2;
289   - wx.switchTab({ url: url, }) //跳到tabbar页
290   - }else{
291   - wx.navigateTo({ url: url, }) //跳到非tabbar页
292   - }
293   - },
294   -
295   - //显示提示,word提示内容,type 0失败,提示 1成功
296   - my_warnning(word,type,that,width){
297   - var warn = that.selectComponent("#warn"); //组件的id
298   - warn.open(word,type,width);
299   - return 1;
300   - },
301   -
302   - //获取会员门店
303   - get_user_store:function (func)
304   - {
305   - var th=this;
306   - this.getConfig2(function (conf) {
307   - //---空会员的情况---
308   - if(!th.globalData.userInfo){
309   - return func(null);
310   - }
311   - if(!th.globalData.pk_store){
312   - var pick_id=0;
313   - //先找一个会员是否有设置默认的地址
314   - if(th.globalData.userInfo.def_pickup_id){
315   - pick_id= th.globalData.userInfo.def_pickup_id
316   - }
317   - //查找会员的注册的地址
318   - else if(th.globalData.userInfo.pickup_id){
319   - //--购买门店是否默认登记门店--
320   - if(conf.switch_list){
321   - var t_swi=JSON.parse(conf.switch_list);
322   - if(t_swi.is_regstores){
323   - pick_id= th.globalData.userInfo.pickup_id
324   - }
325   - }
326   -
327   - }
328   - //---如果会员没有设置默认门店,同时也没有再注册的时候选择门店--
329   - if(pick_id==0) return func(null);
330   - //获取用户注册时候的门店,这个门店不能关闭,同时这个门店的分类不能关闭
331   - th.request.get("/api/weshop/pickup/get/"+os.stoid+"/"+pick_id,{
332   - data:{},
333   - success:function (res) {
334   - th.globalData.pk_store=null;
335   - if(res.data.code==0 && res.data.data && res.data.data.isstop==0){
336   - if(res.data.data.category_id){
337   - th.request.get( "/api/weshop/storagecategory/get/"+os.stoid+"/"+res.data.data.category_id, {
338   - data: {},
339   - success: function (ee) {
340   - if(ee.data.code==0 && ee.data.data ){
341   - if(ee.data.data.is_show==1){
342   - th.globalData.pk_store = res.data.data;
343   - func(th.globalData.pk_store);
344   - }else{
345   - func(null);
346   - }
347   - }else{
348   - func(null);
349   - }
350   - }
351   - })
352   - }else{
353   - th.globalData.pk_store = res.data.data;
354   - func(th.globalData.pk_store);
355   - }
356   - }else{
357   - func(null);
358   - }
359   - }
360   - })
361   - }else{
362   - func(th.globalData.pk_store);
363   - }
364   - })
365   -
366   - },
367   -
368   - //-------获取购物车数量----------
369   - requestCardNum: function() {
370   - var th = this;
371   - th.request.get("/api/weshop/cart/page", {
372   - data: {
373   - store_id: th.globalData.setting.stoid,
374   - user_id: th.globalData.user_id,
375   - },
376   - success: function(e) {
377   - var num = 0;
378   - for (var i = 0; i < e.data.data.pageData.length; i++) {
379   - num += e.data.data.pageData[i].goods_num;
380   - }
381   - wx.setTabBarBadge({ //tabbar右上角添加文本
382   - index: 2, ////tabbar下标
383   - text: '' + num //显示的内容
384   - });
385   - }
386   - });
387   - },
388   -
389   - //------定时等待某个值,有值才进行运算--------
390   - waitfor:function(page,key,pop_value,func){
391   - var n=0;
392   - if(!page.data[key]){
393   - page.data[key]=setInterval(function(){
394   - console.log(page.data[key]);n++;
395   - if(pop_value) {
396   - clearInterval(page.data[key]);
397   - func();
398   - }
399   - if(n>15) clearInterval(page.data[key]);
400   - },1000);
401   - }
402   - },
403   -
404   -
405   - //------定时等待某个值,有值才进行运算--------
406   - waitfor2:function(page,key,pop_value_key,func){
407   - var n=0;
408   - if(!page.data[key]){
409   - page.data[key]=setInterval(function(){
410   - console.log(page.data[key]);n++;
411   - if(page.data[pop_value_key]) {
412   - clearInterval(page.data[key]);
413   - func();
414   - }
415   - if(n>15) clearInterval(page.data[key]);
416   - },1000);
417   - }
418   - }
419   -
420   -
421   -});