Commit 8bb194eacdd71ff528efa57221f27bd57ad3a0d8

Authored by WXD-SEASON\season
2 parents 33548307 90ab03da

Merge branch 'dev_oa_lu8' into dev

components/store_popup/store_popup.js 0 → 100644
  1 +// components/store_popup.js
  2 +var e = getApp(),
  3 + a = e.globalData.setting,
  4 + os = a
  5 +Component({
  6 + /**
  7 + * 组件的属性列表
  8 + */
  9 + properties: {
  10 + store: {
  11 + type: Number,
  12 + value: 0
  13 + }
  14 + },
  15 + lifetimes: {
  16 + attached: function () {
  17 + // 在组件实例进入页面节点树时执行
  18 + this.init()
  19 + },
  20 + detached: function () {
  21 + // 在组件实例被从页面节点树移除时执行
  22 + },
  23 + },
  24 + /**
  25 + * 组件的初始数据
  26 + */
  27 + data: {
  28 + //门店相关
  29 + ismend: 0,
  30 + is_sec_mend: 0,
  31 + sto_sele_name: "", //选中的门店名称
  32 + sto_sele_id: "", //选中的门店id
  33 + sto_sele_distr: "", //选择的门店的配送方式
  34 + is_show_sto_cat: 1, //是否显示门店分类
  35 + only_pk: null,
  36 + all_sto: null,
  37 + sec_sto: null, //选择了的门店分类
  38 + pickpu_list: null, //读出的所有门店list
  39 + def_pickpu_list: null, //一开始5个门店list
  40 + sec_pick_index: 0, //第二级门店选择ID
  41 + fir_pick_index: 0, //第一级门店选择ID
  42 + all_pick_list: null,//所有的门店先记录起来
  43 +
  44 + select_store: 0, //选择更多
  45 + index: 1,
  46 + more_store: 0, //选择门店
  47 + sort_store: 0, //门店分类
  48 + choice_sort_store: 0, //选择分类门店
  49 + new_user: 0, //新用户
  50 +
  51 + def_pick_store: null, // 默认的门店
  52 + fir_def_store: null, //客户默认的门店的
  53 + lat: null, //维度
  54 + lon: null, //经度
  55 +
  56 + is_get_local_ok: 0, //获取坐标是否完成
  57 + region_name: "门店分类", //区域的名字
  58 + is_gps: 1,
  59 + open_ind_store: 0, //哪里打开的门店列表的控制属性
  60 + default_store: {}, //创建添加默认门店地址的对象
  61 +
  62 +
  63 + openSpecModal: 0,
  64 +
  65 + is_get_guide: 0,
  66 + keyword: '', //门店搜索
  67 + sec_i: -1,//选中分类门店 下标
  68 + old_all_sto:null, //分类门店数据
  69 + },
  70 +
  71 + /**
  72 + * 组件的方法列表
  73 + */
  74 + methods: {
  75 + init() {
  76 + getApp().getConfig2((e) => {
  77 + this.setData({
  78 + bconfig: e,
  79 + });
  80 + })
  81 + this.wait_for_store_config()
  82 + this.set_user_mo_store(() => {
  83 + this.get_sto()
  84 + })
  85 + },
  86 + //开启定位
  87 + wait_for_store_config: function () {
  88 + let th = this
  89 + var t_time = setInterval(function () {
  90 + if (th.data.bconfig == null) false;
  91 + var e = th.data.bconfig;
  92 + if (e && e.is_sort_storage) {
  93 + wx.getLocation({
  94 + type: 'gcj02',
  95 + success: function (res) {
  96 + th.data.lat = res.latitude;
  97 + th.data.lon = res.longitude;
  98 + th.data.is_get_local_ok = 1;
  99 + },
  100 + fail: function (res) {
  101 + if (res.errCode == 2) {
  102 + th.setData({
  103 + is_gps: 0
  104 + });
  105 + if (th.data.is_gps == 0) {
  106 + getApp().confirmBox("请开启GPS定位", null, 10000, !1);
  107 + }
  108 +
  109 + } else {
  110 + th.setData({
  111 + is_gps: "3"
  112 + });
  113 + }
  114 +
  115 + th.data.is_get_local_ok = 1;
  116 + }
  117 + })
  118 + } else {
  119 + th.data.is_get_local_ok = 1;
  120 + }
  121 + clearInterval(t_time);
  122 + }, 500)
  123 + },
  124 + set_user_mo_store(func) {
  125 + let th = this;
  126 + let that = th;
  127 +
  128 + //获取用户的默认门店
  129 + getApp().get_user_store(function (e) {
  130 + if (!e) {
  131 + th.data.fir_def_store = {}; //赋值空对象
  132 + return false;
  133 + }
  134 +
  135 + if (getApp().globalData.is_dj_pk) th.setData({ has_def: 1 })
  136 +
  137 + var ee = JSON.parse(JSON.stringify(e));
  138 + //--定时器推迟一下--
  139 + setTimeout(function () {
  140 + if (th.data.fir_goods) var g_distr_type = th.data.fir_goods.distr_type;
  141 + //--如果默认门店的配送方式不对,就不能被选择,这里不控制,如果不一样,就说明配送方式不对--
  142 + if (ee.distr_type != 0 && g_distr_type != 0 && ee.distr_type != g_distr_type) {
  143 + ee.is_no_dis = 1;
  144 + }
  145 +
  146 + var appd = getApp().globalData;
  147 + var w_time = setInterval(function () {
  148 + if (that.data.is_get_local_ok == 0) return false;
  149 + clearInterval(w_time);
  150 + var distance = null;
  151 + var e = JSON.parse(JSON.stringify(ee));
  152 +
  153 + //如果有开启近距离的话,同时距离优不一样了
  154 + if (that.data.lat != null) {
  155 + //如果经纬度有变化的话
  156 + if (e && appd.lat == that.data.lat && appd.lon == that.data.lon && e.distance > 0) {
  157 + that.set_def_storage(e);
  158 + if (func) func();
  159 + } else {
  160 + //要用接口是获取距离,js的计算不准
  161 + getApp().request.promiseGet("/api/weshop/pickup/list", {
  162 + data: {
  163 + store_id: os.stoid,
  164 + pickup_id: e.pickup_id,
  165 + lat: th.data.lat,
  166 + lon: th.data.lon,
  167 + isstop: 0,
  168 + is_pos: 1
  169 + },
  170 + }).then(res => {
  171 + if (res.data.code == 0) {
  172 + e = res.data.data.pageData[0];
  173 + if (e) {
  174 + e.is_no_dis = ee.is_no_dis;
  175 + appd.pk_store = e;
  176 + that.set_def_storage(e);
  177 + }
  178 +
  179 + }
  180 + if (func) func();
  181 + })
  182 + }
  183 + //e.distance = distance;
  184 + appd.lat = that.data.lat;
  185 + appd.lon = that.data.lon;
  186 +
  187 + } else {
  188 + if (e) {
  189 + e.distance = null;
  190 + that.set_def_storage(e);
  191 + }
  192 + if (func) func();
  193 + }
  194 + }, 500)
  195 + }, 700)
  196 + })
  197 +
  198 + },
  199 + //--- 设置一下默认库存的数量 ----
  200 + set_def_storage(ee) {
  201 + var that = this, th = this;
  202 + that.data.fir_def_store = ee;
  203 + that.setData({
  204 + def_pick_store: ee,
  205 + sto_sele_name: ee.pickup_name,
  206 + sto_sele_id: ee.pickup_id,
  207 + sto_sele_distr: ee.distr_type
  208 + })
  209 + },
  210 + //---------拿出门店分类和门店------------
  211 + get_sto() {
  212 + let th = this
  213 + var that = th;
  214 + var self = this;
  215 + var timer_get = setInterval(function () {
  216 + if (th.data.is_get_local_ok == 0) return false;
  217 + var dd = null;
  218 +
  219 + dd = {
  220 + store_id: os.stoid,
  221 + isstop: 0,
  222 + is_pos: 1,
  223 + pageSize: 2000,
  224 + }
  225 +
  226 + //如果有距离的话
  227 + if (th.data.lat != null) {
  228 + dd.lat = th.data.lat;
  229 + dd.lon = th.data.lon;
  230 + }
  231 +
  232 + if (th.data.sele_g && th.data.sele_g.pickup_list) {
  233 + dd.ids = th.data.sele_g.pickup_list
  234 + }
  235 +
  236 + clearInterval(timer_get);
  237 +
  238 + //如果会员是有默认的门店话
  239 + if (!th.data.def_pick_store && th.data.fir_def_store) {
  240 + th.setData({ def_pick_store: th.data.fir_def_store });
  241 + }
  242 + wx.showLoading({
  243 + title: '加载中.'
  244 + });
  245 + //----------获取门店----------------
  246 + getApp().request.promiseGet("/api/weshop/pickup/list", {
  247 + data: dd,
  248 + }).then(res => {
  249 + var e = res;
  250 + wx.hideLoading()
  251 + if (e.data.code == 0 && e.data.data && e.data.data.pageData && e.data.data.pageData.length > 0) {
  252 +
  253 + var his_cate_num = 0;
  254 + for (let i in e.data.data.pageData) {
  255 + let item = e.data.data.pageData[i];
  256 + if (item.category_id > 0) {
  257 + his_cate_num = 1;
  258 + break;
  259 + }
  260 + }
  261 + e.his_cate_num = his_cate_num;
  262 +
  263 + //如果有开启距离的功能,没有设置默认门店,要用最近的门店作为默认门店
  264 + if (dd.lat && (!th.data.def_pick_store || JSON.stringify(th.data.def_pick_store) == '{}') && th.data.bconfig && th.data.bconfig.is_sort_storage) {
  265 + th.setData({
  266 + def_pick_store: e.data.data.pageData[0],
  267 + sto_sele_name: e.data.data.pageData[0].pickup_name,
  268 + sto_sele_id: e.data.data.pageData[0].pickup_id,
  269 + sto_sele_distr: e.data.data.pageData[0].distr_type
  270 + });
  271 + th.data.fir_def_store = e.data.data.pageData[0];
  272 + }
  273 +
  274 + //-- 如果有默认选择门店的时候,要把默认门店放在第一位,修改不要配送方式的判断 --
  275 + if (th.data.def_pick_store && JSON.stringify(th.data.def_pick_store) != '{}') {
  276 + for (var k = 0; k < e.data.data.pageData.length; k++) {
  277 + if (e.data.data.pageData[k].pickup_id == th.data.def_pick_store.pickup_id) {
  278 + e.data.data.pageData.splice(k, 1); //删除
  279 + break;
  280 + }
  281 + }
  282 + e.data.data.pageData.splice(0, 0, th.data.def_pick_store); //添加
  283 + }
  284 +
  285 + th.setData({ all_pick_list: e.data.data.pageData });
  286 +
  287 + setTimeout(function () {
  288 +
  289 + self.deal_pickup(e, th, os); //--普通门店排版--
  290 + }, 800)
  291 +
  292 + }
  293 + })
  294 + }, 200)
  295 +
  296 + },
  297 + //---点击二级之后的选择---
  298 + choose_for_store: function (e) {
  299 + var index_c = e.currentTarget.dataset.ind;
  300 + var th = this;
  301 + th.setData({
  302 + sec_pick_index: index_c,
  303 + fir_pick_index: index_c
  304 + })
  305 +
  306 + },
  307 + choose_for_store_fir: function (e) {
  308 + console.log(e);
  309 + var index_c = e.currentTarget.dataset.ind;
  310 + var th = this;
  311 + th.setData({
  312 + fir_pick_index: index_c
  313 + })
  314 +
  315 + },
  316 + close_popup() {
  317 + this.setData({
  318 + store: 0,
  319 + keyword:''
  320 + })
  321 + },
  322 + //选择更多门店
  323 + more_store: function () {
  324 + this.setData({
  325 + sort_store: 1
  326 + });
  327 + },
  328 + // 返回按钮
  329 + returns: function () {
  330 + this.setData({
  331 + sort_store: 0,
  332 + choice_sort_store: 0
  333 + });
  334 + },
  335 + //---选择分类门店---
  336 + choice_sort_store: function (e) {
  337 + var index = e.currentTarget.dataset.index;
  338 + var region_name = e.currentTarget.dataset.region;
  339 + var item = this.data.all_sto[index];
  340 + this.setData({
  341 + region_name: region_name,
  342 + sort_store: 0,
  343 + choice_sort_store: 1,
  344 + sec_i: index,
  345 + sec_sto: item,
  346 + sec_pick_index: 0
  347 + });
  348 + },
  349 + //------------处理门店---------------
  350 + deal_pickup(e, th, os) {
  351 + // if (!th.data.sele_g) return false
  352 + wx.hideLoading();
  353 + //单总量超出10个的时候,同时门店有分类
  354 + if (e.data.data.total > 10 && e.his_cate_num) {
  355 + getApp().request.get("/api/weshop/storagecategory/page", {
  356 + data: {
  357 + store_id: os.stoid,
  358 + pageSize: 1000,
  359 + orderField: "sort",
  360 + orderType: 'asc',
  361 + },
  362 + success: function (ee) {
  363 + if (ee.data.code == 0) {
  364 + var check_all_cate = 0;
  365 + if (ee.data.data && ee.data.data.pageData && ee.data.data.pageData.length > 0) {
  366 + for (let i in ee.data.data.pageData) {
  367 + let item = ee.data.data.pageData[i];
  368 + if (item.is_show == 1) {
  369 + check_all_cate = 1;
  370 + break
  371 + }
  372 + }
  373 + }
  374 + if (check_all_cate) {
  375 + var sto_cate = ee.data.data.pageData;
  376 + var sto_arr = e.data.data.pageData;
  377 + var newarr = new Array();
  378 + var qita = new Array();
  379 +
  380 +
  381 + var is_del_pk = 0;
  382 + //----要进行门店分组--------
  383 + for (var i = 0; i < sto_arr.length; i++) {
  384 + //找一下这个门店有没有在分类数组内
  385 + var find2 = 0, find2name = "", sort = 0;
  386 + is_del_pk = 0;
  387 + for (var m = 0; m < sto_cate.length; m++) {
  388 + if (sto_arr[i].category_id == sto_cate[m].cat_id) {
  389 + if (sto_cate[m].is_show != 1) {
  390 + is_del_pk = 1;
  391 + sto_arr.splice(i, 1);
  392 + i--;
  393 + } else {
  394 + find2 = sto_cate[m].cat_id;
  395 + find2name = sto_cate[m].cat_name;
  396 + sort = sto_cate[m].sort;
  397 + is_del_pk = 0;
  398 + }
  399 + break;
  400 + }
  401 + }
  402 + if (is_del_pk) continue;
  403 +
  404 + if (newarr.length > 0) {
  405 + var find = 0;
  406 + //如果有找到,那门店就在这个分组内,否则,分类就要排在其他
  407 + if (find2 != 0) {
  408 + for (var ii = 0; ii < newarr.length; ii++) {
  409 + if (sto_arr[i].category_id == newarr[ii].cat_id) {
  410 + newarr[ii].s_arr.push(sto_arr[i]);
  411 + find = 1;
  412 + break;
  413 + }
  414 + }
  415 + if (find == 0) {
  416 + var arr0 = new Array();
  417 + arr0.push(sto_arr[i]);
  418 + var item = {
  419 + cat_id: find2,
  420 + name: find2name,
  421 + sort: sort,
  422 + s_arr: arr0
  423 + };
  424 + newarr.push(item);
  425 + }
  426 + } else {
  427 + qita.push(sto_arr[i]);
  428 + }
  429 + } else {
  430 + //如果有找到,那门店就在这个分组内,否则,分类就要排在其他
  431 + if (find2 != 0) {
  432 + var arr0 = new Array();
  433 + arr0.push(sto_arr[i]);
  434 + var item = {
  435 + cat_id: find2,
  436 + name: find2name,
  437 + sort: sort,
  438 + s_arr: arr0
  439 + };
  440 + newarr.push(item);
  441 + } else {
  442 + qita.push(sto_arr[i]);
  443 + }
  444 + }
  445 + }
  446 +
  447 + var def_arr = new Array();
  448 + //-- 开始就看10个门店 --
  449 + for (var k = 0; k < 10; k++) {
  450 + if (k == sto_arr.length) break;
  451 + def_arr.push(sto_arr[k]);
  452 + }
  453 +
  454 + th.setData({
  455 + def_pickpu_list: def_arr,
  456 + pickpu_list: ee.data.data.pageData
  457 + });
  458 +
  459 +
  460 + //门店分类要排序下
  461 + function compare(property) {
  462 + return function (a, b) {
  463 + var value1 = a[property];
  464 + var value2 = b[property];
  465 + return value1 - value2;
  466 + }
  467 + }
  468 +
  469 + if (newarr.length > 0)
  470 + newarr.sort(compare("sort"));
  471 +
  472 +
  473 + //----安排其他的分类-----
  474 + if (qita.length > 0) {
  475 + var item = {
  476 + cat_id: -1,
  477 + name: "其他",
  478 + s_arr: qita
  479 + };
  480 + newarr.push(item);
  481 + }
  482 +
  483 + var sd = {
  484 + all_sto: newarr,
  485 + is_show_sto_cat: 1
  486 + }
  487 + if (!sto_arr || sto_arr.length <= 10) {
  488 + sd.is_show_sto_cat = -1;
  489 + sd.only_pk = sto_arr;
  490 + }
  491 + th.setData(sd);
  492 +
  493 + } else {
  494 + th.setData({
  495 + is_show_sto_cat: -1,
  496 + only_pk: e.data.data.pageData
  497 + });
  498 + //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------
  499 + if (!th.data.def_pick_store) {
  500 + th.setData({
  501 + def_pick_store: e.data.data.pageData[0],
  502 + sto_sele_name: e.data.data.pageData[0].pickup_name,
  503 + sto_sele_id: e.data.data.pageData[0].pickup_id,
  504 + sto_sele_distr: e.data.data.pageData[0].distr_type
  505 + })
  506 + }
  507 + }
  508 + } else {
  509 + th.setData({
  510 + is_show_sto_cat: -1,
  511 + only_pk: e.data.data.pageData
  512 + });
  513 + //-----如果没有默认门店,要取第一个门店作为默认店.此时没有门店分类的情况------
  514 + if (!th.data.def_pick_store) {
  515 + th.setData({
  516 + def_pick_store: e.data.data.pageData[0],
  517 + sto_sele_name: e.data.data.pageData[0].pickup_name,
  518 + sto_sele_id: e.data.data.pageData[0].pickup_id,
  519 + sto_sele_distr: e.data.data.pageData[0].distr_type
  520 + })
  521 + }
  522 +
  523 + }
  524 + }
  525 + });
  526 + } else {
  527 + th.setData({
  528 + is_show_sto_cat: 0,
  529 + only_pk: e.data.data.pageData
  530 + });
  531 + //-----如果没有默认门店,要取第一个门店作为默认店------
  532 + if (!th.data.def_pick_store && th.data.bconfig && th.data.bconfig.is_sort_storage) {
  533 + th.setData({
  534 + def_pick_store: e.data.data.pageData[0],
  535 + sto_sele_name: e.data.data.pageData[0].pickup_name,
  536 + sto_sele_id: e.data.data.pageData[0].pickup_id,
  537 + sto_sele_distr: e.data.data.pageData[0].distr_type
  538 + })
  539 + }
  540 + }
  541 + },
  542 +
  543 + check_def_pk: function () {
  544 + let th = this
  545 + th.data.def_pick_store.is_no_dis = 0;
  546 + var def_pick_store = th.data.def_pick_store
  547 + var sele_g = th.data.sele_g;
  548 + var arr = sele_g.pickup_list.split(',');
  549 +
  550 + var idx = arr.findIndex(function (e) {
  551 + return e == def_pick_store.pickup_id;
  552 + })
  553 +
  554 + if (idx == -1) {
  555 + def_pick_store.is_no_dis = 1;
  556 + }
  557 + th.setData({ def_pick_store })
  558 +
  559 + },
  560 + //获取搜索门店输入的值
  561 + input_store: function (e) {
  562 + this.setData({
  563 + keyword: e.detail.value
  564 + })
  565 + },
  566 + //搜索门店
  567 + searchfn() {
  568 + let choice_sort_store = this.data.choice_sort_store
  569 + if (choice_sort_store == 0) { //全局搜索
  570 + let all_pick_list = this.data.all_pick_list
  571 + let def_pickpu_list = this.data.def_pickpu_list
  572 + let keyword = this.data.keyword
  573 + if (keyword) {
  574 + let arr = all_pick_list.filter(item => {
  575 + let i = item.pickup_name.indexOf(keyword)
  576 + if (i > -1) {
  577 + return true
  578 + } else {
  579 + return false
  580 + }
  581 + })
  582 + if (arr && arr.length > 0) {
  583 + if (this.data.is_show_sto_cat == 1) {
  584 + this.setData({
  585 + def_pickpu_list: arr
  586 + })
  587 + } else {
  588 + this.setData({
  589 + only_pk: arr
  590 + })
  591 + }
  592 + } else {
  593 + wx.showToast({
  594 + title: '没有搜索到门店',
  595 + icon: 'none',
  596 + duration: 2000
  597 + })
  598 + }
  599 + } else {
  600 + if (this.data.is_show_sto_cat == 1) {
  601 + this.setData({
  602 + def_pickpu_list: all_pick_list.slice(0, 10)
  603 + })
  604 + } else {
  605 + this.setData({
  606 + only_pk: all_pick_list
  607 + })
  608 + }
  609 +
  610 + }
  611 + } else { //分类下搜索
  612 + let sec_i = this.data.sec_i
  613 + let all_sto = this.data.all_sto
  614 + let old_all_sto = this.data.old_all_sto
  615 + if (!old_all_sto) {
  616 + this.setData({
  617 + old_all_sto:JSON.parse(JSON.stringify(all_sto))
  618 + })
  619 + }
  620 + let sec_sto = this.data.sec_sto
  621 + let sec_arr = this.data.old_all_sto[sec_i].s_arr
  622 + let keyword = this.data.keyword
  623 + let text = 'sec_sto.s_arr'
  624 + if (keyword) {
  625 + let arr = sec_arr.filter(item => {
  626 + let i = item.pickup_name.indexOf(keyword)
  627 + if (i > -1) {
  628 + return true
  629 + } else {
  630 + return false
  631 + }
  632 + })
  633 + if (arr && arr.length > 0) {
  634 + this.setData({
  635 + [text]: arr
  636 + })
  637 + } else {
  638 + wx.showToast({
  639 + title: '没有搜索到门店',
  640 + icon: 'none',
  641 + duration: 2000
  642 + })
  643 + }
  644 + } else {
  645 + if (this.data.old_all_sto) {
  646 + this.setData({
  647 + [text]: this.data.old_all_sto[sec_i].s_arr
  648 + })
  649 + }else{
  650 + this.setData({
  651 + [text]: all_sto[sec_i].s_arr
  652 + })
  653 + }
  654 + }
  655 +
  656 +
  657 + }
  658 + },
  659 + //确定def_pick为选择的门店
  660 + sure_pick: function (e) {
  661 +
  662 + var th = this;
  663 + var item = null;
  664 + var openindstore = th.data.open_ind_store;
  665 + if (th.data.choice_sort_store == 0) {
  666 + var index = th.data.fir_pick_index;
  667 + if (th.data.is_show_sto_cat == 1) {
  668 + item = th.data.def_pickpu_list[index];
  669 + } else {
  670 + item = th.data.only_pk ? th.data.only_pk[index] : null; //当没有门店分类的时候
  671 + }
  672 + } else {
  673 + var index = th.data.sec_pick_index;
  674 + item = th.data.sec_sto.s_arr[index];
  675 + }
  676 +
  677 + if (!item) return false;
  678 +
  679 + // if (!th.data.sele_g) return false;
  680 +
  681 +
  682 +
  683 + this.triggerEvent('callback', item)
  684 +
  685 + th.setData({
  686 + def_pick_store: item,
  687 + sto_sele_name: item.pickup_name,
  688 + sto_sele_id: item.pickup_id,
  689 + sto_sele_distr: item.distr_type,
  690 + store: 0,
  691 + choice_sort_store: 0,
  692 + fir_pick_index: 0,
  693 + openSpecModal: !0,
  694 + });
  695 +
  696 +
  697 + },
  698 + }
  699 +})
... ...
components/store_popup/store_popup.json 0 → 100644
  1 +{
  2 + "component": true,
  3 + "usingComponents": {}
  4 +}
0 5 \ No newline at end of file
... ...
components/store_popup/store_popup.wxml 0 → 100644
  1 +<!--components/store_popup.wxml-->
  2 +<wxs module="filter" src="/utils/filter.wxs"></wxs>
  3 +<block wx:if="{{store}}">
  4 + <view class="mongolia-layer" bindtap="close_popup"></view>
  5 + <view class="popup-frame">
  6 + <block wx:if="{{sort_store==0}}">
  7 + <!-- 头部 标题 -->
  8 + <view class="popup-top flex-space-between">
  9 + <text class="fs32 nearby_store">{{choice_sort_store==0?'附近的门店':region_name}}</text>
  10 + <view>
  11 + <view>
  12 + <icon bindtap="close_popup" class="modal-closes" color="black" size="22" type="cancel"></icon>
  13 + </view>
  14 + <view class="felx choose_more" bindtap="more_store" wx:if="{{is_show_sto_cat>0}}">
  15 + <text class="fs26 red-co" >{{choice_sort_store==0?'更多门店':'返回'}}</text> <view class="bg_rights" ></view>
  16 + </view>
  17 + </view>
  18 + </view>
  19 + <view class="searchbar flex-vertical-between storeListpadd">
  20 + <input class="inputstore fs28" placeholder="输入要搜索的门店" value="{{keyword}}" placeholder-class="fs28" maxlength="16" bindinput="input_store" bindconfirm="searchfn" />
  21 + <view class="search flex-center" bindtap="searchfn">
  22 + <view class="fs28">搜索</view>
  23 + </view>
  24 + </view>
  25 + <!-- 门店列表,最外层的门店列表,一开始 -->
  26 + <view class="store-list">
  27 + <!-- 如果还没有点击更多门店的时候 -->
  28 + <block wx:if="{{choice_sort_store==0}}">
  29 + <!-- 需要for循环 -->
  30 + <block wx:if="{{is_show_sto_cat==1}}">
  31 + <view class="store_choose flex" wx:for="{{def_pickpu_list}}" bindtap="choose_for_store_fir" data-ind="{{index}}">
  32 + <view class="store flex-vertical">
  33 + <!-- 需要点击事件 -->
  34 + <block wx:if="{{index==fir_pick_index}}">
  35 + <view class="circle white xc-hook fs20 red-b">Г</view>
  36 + </block>
  37 + <block wx:else>
  38 + <view class="circle xc-hooks"></view>
  39 + </block>
  40 + <view class="address-frame xc-ash">
  41 + <view class="flex-vertical-between butttem5">
  42 + <view class="flex xc-ash">
  43 + <view class="fs30 xc-black3 address_name">{{item.pickup_name}}</view>
  44 + </view>
  45 + <view>
  46 + <view class="distance fs24 address-val" wx:if="{{item.distance}}">
  47 + 距离:{{ item.distance>1000 ? filter.toFix(item.distance/1000,2)+'km' : filter.toFix(item.distance,0)+"m"}}
  48 + </view>
  49 + </view>
  50 + </view>
  51 + <view class="fs24 xc-ash-9f">地址:{{item.fulladdress}}</view>
  52 + </view>
  53 + </view>
  54 + </view>
  55 + </block>
  56 + <block wx:else>
  57 + <view class="store_choose flex" wx:for="{{only_pk}}" bindtap="choose_for_store_fir" data-ind="{{index}}">
  58 + <view class="store flex-vertical">
  59 + <!-- 需要点击事件 -->
  60 + <block wx:if="{{index==fir_pick_index}}">
  61 + <view class="circle white xc-hook fs20 red-b">Г</view>
  62 + </block>
  63 + <block wx:else>
  64 + <view class="circle xc-hooks"></view>
  65 + </block>
  66 + <view class="address-frame xc-ash">
  67 + <view class="flex-vertical-between ">
  68 + <view class="flex xc-ash">
  69 + <view class="fs30 xc-black3 address_name">{{item.pickup_name}}</view>
  70 + </view>
  71 + <view>
  72 + <view class="distance fs24 address-val" wx:if="{{item.distance}}">
  73 + 距离:{{ item.distance>1000 ? filter.toFix(item.distance/1000,2)+"km" : filter.toFix(item.distance,0)+"m"}}
  74 + </view>
  75 + </view>
  76 + </view>
  77 + <view class="fs24 xc-ash-9f">地址:{{item.fulladdress}}</view>
  78 + </view>
  79 + </view>
  80 + </view>
  81 + </block>
  82 + </block>
  83 + <block wx:else>
  84 + <!-- 如果是点击选择门店分类后显示分类下的门店 -->
  85 + <view class="store_choose flex" wx:for="{{sec_sto.s_arr}}" data-ind="{{index}}" bindtap="choose_for_store">
  86 + <view class="store flex-vertical">
  87 + <!-- 需要点击事件 -->
  88 + <block wx:if="{{index==sec_pick_index}}">
  89 + <view class="circle white xc-hook fs20 red-b">Г</view>
  90 + </block>
  91 + <block wx:else>
  92 + <view class="circle xc-hooks"></view>
  93 + </block>
  94 + <view class="address-frame xc-ash">
  95 + <view class="flex-vertical-between ">
  96 + <view class="flex xc-ash">
  97 + <view class="fs28 xc-black3 address_name">{{item.pickup_name}}</view>
  98 + </view>
  99 + <view>
  100 + <view class="distance fs24 address-val" wx:if="{{item.distance!=null}}">
  101 + 距离:{{item.distance>1000?filter.toFix(item.distance/1000,2)+"km":filter.toFix(item.distance,0)+"m"}}
  102 + </view>
  103 + </view>
  104 + </view>
  105 + <view class="fs24 xc-ash-9f">地址:{{item.fulladdress}}</view>
  106 + </view>
  107 + </view>
  108 + </view>
  109 + </block>
  110 + </view>
  111 + <!-- 门店列表底部 -->
  112 + <view class="store-bottom-frame">
  113 + <view class="store-bottom flex-center">
  114 + <view class="determine red-b fs28 white t-c" bindtap="sure_pick" data-openindstore="{{open_ind_store}}">
  115 + 确定
  116 + </view>
  117 + <!-- <view class="default t-c fs28" bindtap="set_def_pick" data-openindstore="{{open_ind_store}}">
  118 + 设为默认
  119 + </view> -->
  120 + </view>
  121 + </view>
  122 + </block>
  123 + <block wx:else>
  124 + <view class="popup-top flex-space-between">
  125 + <text class="fs32 nearby_store">门店分类选择</text>
  126 + <view>
  127 + <view>
  128 + <icon bindtap="close_popup" class="modal-closes" color="black" size="22" type="cancel"></icon>
  129 + </view>
  130 + <view class="felx choose_mores" bindtap="returns">
  131 + <text class="fs26 red-co">返回</text>
  132 + </view>
  133 + </view>
  134 + </view>
  135 + <view class="sort_store_list">
  136 + <view class="sort-store-frame" wx:for="{{all_sto}}" data-index="{{index}}" bindtap="choice_sort_store" data-region="{{item.name}}">
  137 + <view class="sort-store flex-vertical-between">
  138 + <view class="fs30" di>{{item.name}}</view>
  139 + <view class="black_rights-frame">
  140 + <view class="black_rights"></view>
  141 + </view>
  142 + </view>
  143 + </view>
  144 + </view>
  145 + </block>
  146 + </view>
  147 +</block>
... ...
components/store_popup/store_popup.wxss 0 → 100644
  1 +/* 中间等距两边贴边 */
  2 +.flex-space-between{
  3 + display: flex;
  4 + justify-content:space-between;
  5 +}
  6 +.flex{display: flex}
  7 +/* 垂直居中 */
  8 +.flex-vertical{
  9 + display:flex;
  10 + align-items:center;
  11 + }
  12 + /* 圆 */
  13 +.circle{
  14 + border-radius: 50%;
  15 + -moz-border-radius: 50%;
  16 + -webkit-border-radius: 50%;
  17 +}
  18 +/* 7.26 */
  19 +.white{
  20 + color: #fff;
  21 +}
  22 +.red-b{
  23 + background: #d60021;
  24 +}
  25 +.fs20{
  26 + font-size: 20rpx;
  27 +}
  28 +.xc-ash{
  29 + color: #b9b9b9;
  30 + }
  31 +/* 水平垂直 */
  32 +.flex-center{
  33 + display:flex;
  34 + justify-content:center;
  35 + align-items:center;
  36 + }
  37 +/* 垂直居中 中间等距两边贴边 7.13*/
  38 +.flex-vertical-between{
  39 + display:flex;
  40 + align-items:center;
  41 + justify-content:space-between;
  42 + }
  43 + .xc-ash{
  44 + color: #b9b9b9;
  45 + }
  46 + .fs30{
  47 + font-size:30rpx;
  48 +}
  49 +.xc-black3{
  50 + color: #333;
  51 +}
  52 + .fs28{
  53 + font-size: 28rpx;
  54 +}
  55 + .fs32{
  56 + font-size:32rpx;
  57 +}
  58 +.fs26{
  59 + font-size: 26rpx;
  60 +}
  61 +.red-co{
  62 + color: #d60021;
  63 +
  64 +}
  65 +/* 门店分类列表 */
  66 +.sort_store_list {
  67 + max-height: 700rpx;
  68 + overflow: hidden;
  69 + overflow-y: scroll;
  70 + width: 95%;
  71 + margin: auto;
  72 +}
  73 +
  74 +.sort_store_list .sort-store-frame {
  75 + width: 100%;
  76 + height: 100rpx;
  77 + line-height: 100rpx;
  78 + border-bottom: 1rpx solid #eee;
  79 +
  80 +}
  81 +
  82 +.sort_store_list .sort-store-frame .sort-store {
  83 + width: 94.5%;
  84 + margin: auto;
  85 +}
  86 +.black_rights-frame {
  87 + width: 50%;
  88 +}
  89 +.black_rights-frame .black_rights {
  90 + border-top: 3rpx solid;
  91 + border-right: 3rpx solid;
  92 + transform: rotate(45deg);
  93 + display: inline-block;
  94 + width: 20rpx;
  95 + height: 20rpx;
  96 +}
  97 +/* 选择门店的弹窗 */
  98 +.mongolia-layer {
  99 + position: fixed;
  100 + left: 0;
  101 + top: 0;
  102 + right: 0;
  103 + bottom: 0;
  104 + z-index: 11;
  105 + background: rgba(0, 0, 0, 0.4);
  106 + width: 100%;
  107 + height: 91.9%;
  108 +
  109 +}
  110 +
  111 +.popup-frame {
  112 + position: fixed;
  113 + z-index: 20;
  114 + background: white;
  115 + width: 100%;
  116 + border-radius: 20rpx 20rpx 0 0;
  117 + height: auto;
  118 + bottom: 0;
  119 +}
  120 +
  121 +.popup-top {
  122 + border-bottom: 1rpx solid #eee;
  123 + height: 155rpx;
  124 + width: 95%;
  125 + margin: auto;
  126 + line-height: 155rpx;
  127 +
  128 +}
  129 +.fs32{
  130 + font-size: 32rpx;
  131 +}
  132 +.nearby_store {
  133 + margin-left: 17rpx;
  134 +}
  135 +.modal-closes {
  136 + position: absolute;
  137 + right: 30rpx;
  138 + top: -15rpx;
  139 + height: 25rpx;
  140 +
  141 +}
  142 +.choose_mores {
  143 + margin-top: 30rpx;
  144 + margin-right: 15rpx;
  145 +
  146 +}
  147 +.choose_more {
  148 + margin-top: 40rpx;
  149 + margin-right: 20rpx;
  150 +
  151 +}
  152 +.bg_rights {
  153 + border-top: 2rpx solid;
  154 + border-right: 2rpx solid;
  155 + transform: rotate(45deg);
  156 + display: inline-block;
  157 + width: 15rpx;
  158 + height: 15rpx;
  159 + border-color: #da0b31;
  160 +}
  161 +.searchbar {
  162 + height: 95rpx;
  163 + border-bottom: 2rpx solid rgb(238, 238, 238);
  164 +}
  165 +.storeListpadd {
  166 + padding: 0rpx 31rpx;
  167 +}
  168 +.search {
  169 + width: 125rpx;
  170 + height: 45rpx;
  171 + line-height: 45rpx;
  172 + background-color: rgb(219, 27, 52);
  173 + border-radius: 30rpx;
  174 + color: rgb(255, 255, 255);
  175 +}
  176 +.inputstore {
  177 + width: 510rpx;
  178 + height: 43rpx;
  179 + line-height: 43rpx;
  180 + border-radius: 30rpx;
  181 + border: 2rpx solid rgb(238, 238, 238);
  182 + padding-left: 30rpx;
  183 +}
  184 +
  185 +.store-list {
  186 + width: 95%;
  187 + min-height: 300rpx;
  188 + overflow-y: scroll;
  189 + margin: auto;
  190 + max-height: 610rpx;
  191 +}
  192 +.store-list .store_choose {
  193 + width: 100%;
  194 + height: 120rpx;
  195 + line-height: 125rpx;
  196 + border-bottom: 1rpx solid #eee;
  197 + padding: 10rpx 0;
  198 +}
  199 +
  200 +.store-list .store_choose .store {
  201 + width: 100%;
  202 + margin: auto;
  203 + line-height: 37rpx;
  204 + padding-left: 20rpx;
  205 +
  206 +}
  207 +.xc-hook {
  208 + width: 35rpx;
  209 + height: 35rpx;
  210 + transform: rotate(-145deg);
  211 + line-height: 37rpx;
  212 + text-align: center;
  213 +}
  214 +.address-frame {
  215 + width: 93%;
  216 + margin-left: 7rpx;
  217 +
  218 +}
  219 +.address_name {
  220 + margin-right: 10rpx;
  221 + width: 360rpx;
  222 +
  223 +}
  224 +.fs24{
  225 + font-size: 24rpx !important;
  226 +}
  227 +.xc-ash-9f{
  228 + color: #9fa1a0;
  229 +
  230 +}
  231 +.t-c {
  232 + text-align: center;
  233 +}
  234 +.distance {
  235 + padding-left: 20rpx;
  236 + padding-right: 20rpx;
  237 + background: #eee;
  238 + border-radius: 20rpx;
  239 + /* margin-right: 5rpx; */
  240 + color: #999;
  241 + height: 38rpx;
  242 + line-height: 38rpx;
  243 + position: relative;
  244 + top: 5rpx;
  245 +
  246 +}
  247 +.address-val {
  248 + height: 38rpx;
  249 + line-height: 38rpx;
  250 +
  251 +}
  252 +.butttem5 {
  253 + margin-bottom: 5rpx;
  254 +}
  255 +.store-bottom-frame {
  256 + width: 95%;
  257 + margin: auto;
  258 +
  259 +}
  260 +.store-bottom {
  261 + width: 85%;
  262 + margin: auto;
  263 + height: 90rpx;
  264 +}
  265 +.determine {
  266 + width: 260rpx;
  267 + height: 55rpx;
  268 + border-radius: 50rpx;
  269 + line-height: 55rpx;
  270 +}
  271 +
  272 +.default {
  273 + width: 260rpx;
  274 + height: 55rpx;
  275 + border: 3rpx solid #c8c8c8;
  276 + border-radius: 50rpx;
  277 + line-height: 55rpx;
  278 +}
  279 +.xc-hooks {
  280 + width: 30rpx;
  281 + height: 30rpx;
  282 + border: 1rpx solid #999;
  283 +}
0 284 \ No newline at end of file
... ...
pages/user/user_spsy/user_spsy.js
... ... @@ -5,7 +5,7 @@ var ut = require(&#39;../../../utils/util&#39;);
5 5 var regeneratorRuntime = require('../../../utils/runtime.js');
6 6  
7 7 Page({
8   - /**
  8 + /**
9 9 * 页面的初始数据
10 10 */
11 11 data: {
... ... @@ -15,7 +15,8 @@ Page({
15 15 page: 1,
16 16 isLoading: 0,
17 17 no_more: 0,
18   - is_use: 0 //领取状态
  18 + is_use: 0, //领取状态
  19 + is_appoint_storage:0 //是否要登记门店才可以领取 0是不用,1要登记
19 20 },
20 21 /**
21 22 * 生命周期函数--监听页面加载
... ... @@ -41,6 +42,14 @@ Page({
41 42 * 生命周期函数--监听页面显示
42 43 */
43 44 onShow: function () {
  45 + let th=this
  46 + //先获取是否有关闭使用优惠券
  47 + getApp().getConfig2(function (ee) {
  48 + var json_d = JSON.parse(ee.switch_list);
  49 + th.setData({
  50 + is_appoint_storage:json_d.is_appoint_storage,//是否要登记门店才可以领取 0是不用,1要登记
  51 + });
  52 + }, 1);
44 53 getApp().check_can_share();
45 54 },
46 55 async getQrCode(FormId,GradeId) {
... ... @@ -64,6 +73,43 @@ Page({
64 73 }
65 74 }
66 75 },
  76 + //门店回调
  77 + async callback(e){
  78 + let item = e.detail;
  79 + console.log('门店信息');
  80 + console.log(item);
  81 + if (item && item.pickup_no) {
  82 + let qr_code_object=this.data.qr_code_object
  83 + let data={
  84 + store_id:os.stoid,//商家编号
  85 + user_id:getApp().globalData.user_id, //会员编号
  86 + // storageId:item.pickup_no, //门店编号
  87 + storageId:item.keyid,
  88 + writeOffCode:qr_code_object.WriteOffCode,//核销码
  89 + }
  90 + let res = await getApp().request.promisePut("/api/weshop/users/grade/storage/update", {
  91 + data: data
  92 + });
  93 + if (res && res.data && res.data.code==0) {
  94 + let text='qr_code_object.StorageID'
  95 + this.setData({
  96 + [text]:item.keyid
  97 + })
  98 + }else{
  99 + wx.showToast({
  100 + title: '门店选择失败',
  101 + icon: 'none',
  102 + duration: 2000
  103 + })
  104 + }
  105 + }else{
  106 + wx.showToast({
  107 + title: '门店选择失败',
  108 + icon: 'none',
  109 + duration: 2000
  110 + })
  111 + }
  112 + },
67 113 async requestData() {
68 114 if (this.data.no_more) return false;
69 115 if (this.data.isLoading) return false;
... ... @@ -159,5 +205,11 @@ Page({
159 205  
160 206 close: function () {
161 207 this.getQrCode(this.data.FormId)
  208 + },
  209 +
  210 + select_product(){
  211 + this.setData({
  212 + store:1
  213 + })
162 214 }
163 215 })
164 216 \ No newline at end of file
... ...
pages/user/user_spsy/user_spsy.json
1 1 {
2 2 "navigationBarTitleText": "免费领取",
3 3 "usingComponents": {
4   - "qr_code": "/components/qr_code/qr_code"
  4 + "qr_code": "/components/qr_code/qr_code",
  5 + "store_popup":"/components/store_popup/store_popup"
5 6 }
6 7 }
7 8 \ No newline at end of file
... ...
pages/user/user_spsy/user_spsy.wxml
... ... @@ -13,10 +13,16 @@
13 13 已使用{{list[0].freebh}}
14 14 </view> -->
15 15 <view wx:if="{{is_use}}" class="btn1">已使用</view>
16   - <view wx:else bindtap="show_hxm" data-type="1" class="btn">立即使用</view>
  16 + <block wx:else>
  17 + <view wx:if="{{!is_appoint_storage || qr_code_object.StorageID}}" bindtap="show_hxm" data-type="1" class="btn">立即使用</view>
  18 + <view wx:else bindtap="select_product" data-type="1" class="btn">登记取货</view>
  19 + </block>
17 20 <!-- <view bindtap="right_use" class="btn">立即使用</view></view> -->
18 21 </view>
19 22 </view>
20 23  
21 24 <!-- 弹出框扫描 -->
22   -<qr_code id="qc_com" bindclose="close"></qr_code>
23 25 \ No newline at end of file
  26 +<qr_code id="qc_com" bindclose="close"></qr_code>
  27 +
  28 +<!-- 门店选择弹窗 -->
  29 +<store_popup store="{{store}}" bindcallback="callback" ></store_popup>
24 30 \ No newline at end of file
... ...