Commit 5e5cdb226df130dca9bb8081ed6722431ef2bd3c

Authored by 前端开发-罗建龙
1 parent 00e95f17

OA单优化 售前分享

packageC/pages/presell/goodsInfo/goodsInfo.js
... ... @@ -7,7 +7,7 @@ var ut = require("../../../../utils/util.js"),
7 7 oo = s.globalData,
8 8 o = s.globalData.setting,
9 9 os = o;
10   -//评价加载更多
  10 +//评价加载更多
11 11 var more = function (e) {
12 12 return e && e.__esModule ? e : {
13 13 default: e
... ... @@ -250,13 +250,13 @@ Page({
250 250  
251 251 share_hidden: false,
252 252 pre_arr: null,
253   -
254   - hiddenCS: true,
  253 +
  254 + hiddenCS: true,
255 255 },
256 256  
257 257 //------初始化加载----------
258 258 onLoad: function (t) {
259   - self = this;
  259 + self = this;
260 260 var ee = this, that = ee, th = ee,
261 261 pre_id = t.pre_id,
262 262 gid = t.goods_id,
... ... @@ -264,8 +264,8 @@ Page({
264 264 first_leader = t.first_leader,
265 265 room_id = t.room_id,
266 266 room_user_share = t.room_user_share; //如果是会员分享带有room_id的话,那么接下来会员分享就不传room_id
267   - //检查测肤
268   - getApp().check_skin_face(t,0,gid);
  267 + //检查测肤
  268 + getApp().check_skin_face(t, 0, gid);
269 269  
270 270 //-- 自定义海报 --
271 271 getApp().request.promiseGet("/api/weshop/goods/poster/page", {
... ... @@ -314,7 +314,7 @@ Page({
314 314 }
315 315  
316 316 this.setData({
317   - gid:gid,pre_id:pre_id,presell_id:presell_id
  317 + gid: gid, pre_id: pre_id, presell_id: presell_id
318 318 })
319 319  
320 320 if (first_leader) {
... ... @@ -569,24 +569,24 @@ Page({
569 569 fir_quan = res1.data.data.pageData;
570 570 })
571 571 }
572   - //过滤不是本商品的单品优惠券-------------------
573   - if(fir_quan.length > 0 ){
574   - let goodInfo = ee.data.data
575   - for (let index = fir_quan.length-1; index >= 0; index--) {
576   - if (fir_quan[index].useobjecttype==20) { //判断是单品优惠券
577   - if (fir_quan[index].useobjectno != goodInfo.goods_sn) {
578   - fir_quan.splice(index,1)
579   - }
580   - }
581   - }
582   - }
583   - let arr=[]
584   - let length = fir_quan.length
585   - if (length <= 3) {
586   - arr=fir_quan
587   - }else{
588   - arr=fir_quan.splice(0,3);
  572 + //过滤不是本商品的单品优惠券-------------------
  573 + if (fir_quan.length > 0) {
  574 + let goodInfo = ee.data.data || {}
  575 + for (let index = fir_quan.length - 1; index >= 0; index--) {
  576 + if (fir_quan[index].useobjecttype == 20) { //判断是单品优惠券
  577 + if (fir_quan[index].useobjectno != goodInfo.goods_sn) {
  578 + fir_quan.splice(index, 1)
  579 + }
589 580 }
  581 + }
  582 + }
  583 + let arr = []
  584 + let length = fir_quan.length
  585 + if (length <= 3) {
  586 + arr = fir_quan
  587 + } else {
  588 + arr = fir_quan.splice(0, 3);
  589 + }
590 590 //--------获取视频图片---------
591 591 await getApp().request.promiseGet("/api/weshop/goodsVideos/get/" + os.stoid + "/" + ee.data.gid, {
592 592 1: 1
... ... @@ -614,7 +614,7 @@ Page({
614 614  
615 615 //---展示---
616 616 onShow: function () {
617   - getApp().check_can_share();
  617 + getApp().check_can_share();
618 618 var goods_list = null, th = this, that = this;
619 619  
620 620 //-- 如果是预览图片,页面不重新更新 --
... ... @@ -689,8 +689,8 @@ Page({
689 689  
690 690 //-- 把商品的赋值 --
691 691 ee.data.fir_goods = JSON.parse(JSON.stringify(t.data.data));
692   - ee.data.sele_g_id=t.data.data.goods_id;
693   - ee.data.sele_g=t.data.data;
  692 + ee.data.sele_g_id = t.data.data.goods_id;
  693 + ee.data.sele_g = t.data.data;
694 694  
695 695 //获取用户的默认门店
696 696 getApp().get_user_store(function (e) {
... ... @@ -698,7 +698,7 @@ Page({
698 698 th.data.fir_def_store = {}; //赋值空对象
699 699 return false;
700 700 }
701   - if(getApp().globalData.is_dj_pk) th.setData({has_def:1})
  701 + if (getApp().globalData.is_dj_pk) th.setData({ has_def: 1 })
702 702  
703 703 var ee = JSON.parse(JSON.stringify(e));
704 704  
... ... @@ -1062,7 +1062,7 @@ Page({
1062 1062  
1063 1063 newd.goods_price = th.data.prom_price;
1064 1064 newd.member_goods_price = th.data.prom_price,
1065   - newd.prom_type = 8;
  1065 + newd.prom_type = 8;
1066 1066 newd.prom_id = o.prom_id;
1067 1067  
1068 1068 if (o.store_count <= 0) return s.my_warnning("库存已为空!", 0, th);
... ... @@ -1101,8 +1101,8 @@ Page({
1101 1101 return s.my_warnning("库存不足!", 0, th);
1102 1102 }
1103 1103  
1104   - if (item.goods_num + th.data.goodsInputNum >th.data.pre_arr.presell_sumqty-th.data.pre_arr.buy_goodnum) {
1105   - return s.my_warnning("库存不足!", 0, th);
  1104 + if (item.goods_num + th.data.goodsInputNum > th.data.pre_arr.presell_sumqty - th.data.pre_arr.buy_goodnum) {
  1105 + return s.my_warnning("库存不足!", 0, th);
1106 1106 }
1107 1107  
1108 1108 var updata = {
... ... @@ -1173,10 +1173,10 @@ Page({
1173 1173 app.set_b_now(e);
1174 1174  
1175 1175 //如果是全额付款的话
1176   - if(this.data.presellForm.presell_type==1){
1177   - getApp().goto("/packageC/pages/presell/cart/cart2")
1178   - }else{
1179   - getApp().goto("/packageC/pages/presell/cart/cart2_pre");
  1176 + if (this.data.presellForm.presell_type == 1) {
  1177 + getApp().goto("/packageC/pages/presell/cart/cart2")
  1178 + } else {
  1179 + getApp().goto("/packageC/pages/presell/cart/cart2_pre");
1180 1180 }
1181 1181 },
1182 1182  
... ... @@ -1230,8 +1230,8 @@ Page({
1230 1230 }
1231 1231  
1232 1232 var e = th.data.sele_g.store_count;
1233   - var e2=th.data.pre_arr.presell_sumqty-th.data.pre_arr.buy_goodnum;
1234   - if(e2<e) e=e2;
  1233 + var e2 = th.data.pre_arr.presell_sumqty - th.data.pre_arr.buy_goodnum;
  1234 + if (e2 < e) e = e2;
1235 1235  
1236 1236 if (!e) e = 0;
1237 1237 //库存不足,不增加
... ... @@ -1297,14 +1297,14 @@ Page({
1297 1297  
1298 1298 //判断是不是优惠促销
1299 1299 check_is_prom_goods: function (callback) {
1300   - if(!this.data.sele_g) return false;
  1300 + if (!this.data.sele_g) return false;
1301 1301 var th = this;
1302 1302 var usr = getApp().globalData.userInfo;
1303 1303 if (this.data.sele_g.prom_type != 0 && this.data.sele_g.prom_type != 3) {
1304 1304 callback();
1305 1305 } else {
1306 1306 //-- 判断有没有优惠活动 --
1307   - getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + th.data.sele_g.goods_id + "/0"+"/"+getApp().globalData.user_id, {}).then(res => {
  1307 + getApp().request.promiseGet("/api/weshop/goods/getGoodsPromList/" + os.stoid + "/" + th.data.sele_g.goods_id + "/0" + "/" + getApp().globalData.user_id, {}).then(res => {
1308 1308 if (res.data.code == 0) {
1309 1309 var r_data = res.data.data;
1310 1310 th.data.prom_goods = r_data.promGoodsLists;
... ... @@ -1461,38 +1461,38 @@ Page({
1461 1461 contactService: function () {
1462 1462 getApp().com_call(this);
1463 1463 },
1464   -
1465   - // 获取客服电话
1466   - getTel() {
1467   - return new Promise((resolve, reject) => {
1468   - s.getConfig(function (t) {
1469   - if (t.store_tel == undefined) {
1470   - getApp().request.get("/api/weshop/store/get/" + os.stoid, {
1471   - isShowLoading: 1,
1472   - data: {},
1473   - success: function (rs) {
1474   - getApp().globalData.config = rs.data.data;
1475   - if (rs.data.data.store_tel == null && rs.data.data.store_tel == undefined) {
1476   - getApp().my_warnning("商家未设置电话", 0, th);
1477   - return false;
1478   - }
1479   - self.setData({
1480   - store_tel: rs.data.data.store_tel,
1481   - });
1482   - // s.confirmBox("请联系客服:" + rs.data.data.store_tel);
1483   - }
1484   - })
1485   - } else {
1486   - self.setData({
1487   - store_tel: t.store_tel,
1488   - });
1489   - // s.confirmBox("请联系客服:" + t.store_tel);
1490   - };
1491   - resolve();
1492   - });
1493   - });
1494   - },
1495   -
  1464 +
  1465 + // 获取客服电话
  1466 + getTel() {
  1467 + return new Promise((resolve, reject) => {
  1468 + s.getConfig(function (t) {
  1469 + if (t.store_tel == undefined) {
  1470 + getApp().request.get("/api/weshop/store/get/" + os.stoid, {
  1471 + isShowLoading: 1,
  1472 + data: {},
  1473 + success: function (rs) {
  1474 + getApp().globalData.config = rs.data.data;
  1475 + if (rs.data.data.store_tel == null && rs.data.data.store_tel == undefined) {
  1476 + getApp().my_warnning("商家未设置电话", 0, th);
  1477 + return false;
  1478 + }
  1479 + self.setData({
  1480 + store_tel: rs.data.data.store_tel,
  1481 + });
  1482 + // s.confirmBox("请联系客服:" + rs.data.data.store_tel);
  1483 + }
  1484 + })
  1485 + } else {
  1486 + self.setData({
  1487 + store_tel: t.store_tel,
  1488 + });
  1489 + // s.confirmBox("请联系客服:" + t.store_tel);
  1490 + };
  1491 + resolve();
  1492 + });
  1493 + });
  1494 + },
  1495 +
1496 1496 //-------获取购物车数量----------
1497 1497 requestCardNum: function () {
1498 1498 var t = this;
... ... @@ -1532,7 +1532,7 @@ Page({
1532 1532 b[i] = this.data.iurl + e[i];
1533 1533 }
1534 1534 this.data.show_prew_img = 1;
1535   - getApp().pre_img2(b,t)
  1535 + getApp().pre_img2(b, t)
1536 1536  
1537 1537 },
1538 1538  
... ... @@ -1543,16 +1543,16 @@ Page({
1543 1543 b[i] = this.data.iurl + e[i];
1544 1544 }
1545 1545 this.data.show_prew_img = 1;
1546   - getApp().pre_img2(b,t)
  1546 + getApp().pre_img2(b, t)
1547 1547 },
1548 1548  
1549 1549 previewGoodsCommentImgs: function (t) {
1550 1550 var e = this,
1551 1551 a = this.data.data.comment[t.currentTarget.dataset.cidx].img;
1552   - getApp().globalData.no_clear=1;
  1552 + getApp().globalData.no_clear = 1;
1553 1553 a = a.map(function (t) {
1554 1554 return e.data.url + t;
1555   - }), getApp().pre_img2(a,t);
  1555 + }), getApp().pre_img2(a, t);
1556 1556 this.data.show_prew_img = 1;
1557 1557 },
1558 1558 closePromModal: function () {
... ... @@ -1567,19 +1567,20 @@ Page({
1567 1567 },
1568 1568  
1569 1569 //--点击分享事件---
1570   - onShareAppMessage: function (t) { getApp().globalData.no_clear=1;
  1570 + onShareAppMessage: function (t) {
  1571 + getApp().globalData.no_clear = 1;
1571 1572  
1572 1573 var th = this;
1573   - var price = th.data.pre_arr.presell_price;
  1574 + var price = th.data.pre_arr.presell_price;
1574 1575 var img = th.data.data.original_img;
1575   - var title = th.data.presellForm.share_title;
  1576 + var title = th.data.presellForm.share_title;
1576 1577 if (!title) title = th.data.prom_act.title;
1577 1578 if (th.data.prom_type == 4) title = th.data.prom_act.name;
1578 1579  
1579 1580 //if (th.data.presellForm.share_img)
1580 1581 // img = th.data.iurl + th.data.presellForm.share_img;
1581 1582  
1582   - var url = "/packageC/pages/presell/goodsInfo/goodsInfo?goods_id=" + th.data.gid+"&pre_id="+th.data.pre_arr.id;
  1583 + var url = "/packageC/pages/presell/goodsInfo/goodsInfo?goods_id=" + th.data.gid + "&pre_id=" + th.data.pre_arr.id;
1583 1584 if (getApp().globalData.user_id) {
1584 1585 url += "&first_leader=" + getApp().globalData.user_id;
1585 1586 }
... ... @@ -1597,13 +1598,13 @@ Page({
1597 1598 path: url,
1598 1599 imageUrl: img,
1599 1600 };
1600   -
  1601 +
1601 1602 ob.title += '\n' + th.data.presellForm.share_remark;
1602   -
1603   -
1604   - console.log(ob,888);
1605 1603  
1606   -
  1604 +
  1605 + console.log(ob, 888);
  1606 +
  1607 +
1607 1608 return ob;
1608 1609  
1609 1610 },
... ... @@ -1626,22 +1627,22 @@ Page({
1626 1627  
1627 1628 //----------装载同一活动中的商品----------
1628 1629 async get_sku(stoid, gd, g_id, is_normal, func) {
1629   - var tt = this, arrdata = null;
1630   - var now = ut.gettimestamp();
1631   - var rq_data={
1632   - store_id: o.stoid,
1633   - sku: gd.sku,
1634   - more_spec: gd.more_spec,
1635   - isonsale: 1,
1636   - is_on_sale: 1,
1637   - pageSize: 500,
1638   - orderField: 'gg_ordid,goods_spec,sort',
1639   - prom_type: 8,
1640   - };
  1630 + var tt = this, arrdata = null;
  1631 + var now = ut.gettimestamp();
  1632 + var rq_data = {
  1633 + store_id: o.stoid,
  1634 + sku: gd.sku,
  1635 + more_spec: gd.more_spec,
  1636 + isonsale: 1,
  1637 + is_on_sale: 1,
  1638 + pageSize: 500,
  1639 + orderField: 'gg_ordid,goods_spec,sort',
  1640 + prom_type: 8,
  1641 + };
1641 1642  
1642   - if(tt.data.presellForm && tt.data.presellForm.id){
1643   - rq_data.prom_id=tt.data.presellForm.id;
1644   - }
  1643 + if (tt.data.presellForm && tt.data.presellForm.id) {
  1644 + rq_data.prom_id = tt.data.presellForm.id;
  1645 + }
1645 1646  
1646 1647 await getApp().request.promiseGet("/api/weshop/goods/page", {
1647 1648 data: rq_data
... ... @@ -1772,31 +1773,31 @@ Page({
1772 1773  
1773 1774 //选择了不同的规格的时候要判断是不是有活动正在进行中
1774 1775 async sele_spec_chech_activity() {
1775   - var prom = null, goodsinfo = this.data.sele_g, th = this;
1776   -
1777   - var all_pre_goods=th.data.all_pre_goods;
1778   - if(all_pre_goods){
1779   - var userInfo = getApp().globalData.userInfo;
1780   - var pre_data = { store_id: os.stoid, is_end: 0, timetype: 1, isuse: 1, goods_id: th.data.gid };
1781   - if (userInfo) {
1782   - pre_data.user_id = userInfo.user_id;
1783   - }
1784   - await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/page", {
1785   - data: pre_data,
1786   - }).then(e => {
1787   - if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) {
1788   - all_pre_goods=e.data.data.pageData;
1789   - th.data.all_pre_goods=e.data.data.pageData;
1790   - }
1791   - })
  1776 + var prom = null, goodsinfo = this.data.sele_g, th = this;
  1777 +
  1778 + var all_pre_goods = th.data.all_pre_goods;
  1779 + if (all_pre_goods) {
  1780 + var userInfo = getApp().globalData.userInfo;
  1781 + var pre_data = { store_id: os.stoid, is_end: 0, timetype: 1, isuse: 1, goods_id: th.data.gid };
  1782 + if (userInfo) {
  1783 + pre_data.user_id = userInfo.user_id;
1792 1784 }
1793   -
1794   - var idx=all_pre_goods.findIndex(function (ele) {
1795   - return ele.goods_id==goodsinfo.goods_id;
  1785 + await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/page", {
  1786 + data: pre_data,
  1787 + }).then(e => {
  1788 + if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) {
  1789 + all_pre_goods = e.data.data.pageData;
  1790 + th.data.all_pre_goods = e.data.data.pageData;
  1791 + }
1796 1792 })
1797   - var pre_arr =all_pre_goods[idx];
1798   - th.setData({ pre_arr: pre_arr })
1799   - th.data.prom_buy_limit=pre_arr.vip_butyqty;
  1793 + }
  1794 +
  1795 + var idx = all_pre_goods.findIndex(function (ele) {
  1796 + return ele.goods_id == goodsinfo.goods_id;
  1797 + })
  1798 + var pre_arr = all_pre_goods[idx];
  1799 + th.setData({ pre_arr: pre_arr })
  1800 + th.data.prom_buy_limit = pre_arr.vip_butyqty;
1800 1801 },
1801 1802  
1802 1803  
... ... @@ -1887,7 +1888,7 @@ Page({
1887 1888 th.setData({ all_pick_list: e.data.data.pageData });
1888 1889  
1889 1890 //--获取线下库存,而且不是新的门店规则, 同时是普通购买的时候,或者同时不能是活动,秒杀,拼团,积分购 预售--
1890   - if (th.data.sales_rules == 2 && !th.data.is_newsales_rules && ((th.data.prom_type != 1 && th.data.prom_type != 6 && th.data.prom_type != 4 && th.data.prom_type !=8 ) || is_normal == 1)) {
  1891 + if (th.data.sales_rules == 2 && !th.data.is_newsales_rules && ((th.data.prom_type != 1 && th.data.prom_type != 6 && th.data.prom_type != 4 && th.data.prom_type != 8) || is_normal == 1)) {
1891 1892 setTimeout(function () {
1892 1893 th.deal_pickup_dline(e);
1893 1894 }, 800)
... ... @@ -1923,15 +1924,15 @@ Page({
1923 1924 success: function (ee) {
1924 1925 if (ee.data.code == 0) {
1925 1926  
1926   - var check_all_cate=0;
1927   - if (ee.data.data && ee.data.data.pageData && ee.data.data.pageData.length > 0){
1928   - for(let i in ee.data.data.pageData){
1929   - let item=ee.data.data.pageData[i];
1930   - if(item.is_show==1){
1931   - check_all_cate=1;break
1932   - }
1933   - }
  1927 + var check_all_cate = 0;
  1928 + if (ee.data.data && ee.data.data.pageData && ee.data.data.pageData.length > 0) {
  1929 + for (let i in ee.data.data.pageData) {
  1930 + let item = ee.data.data.pageData[i];
  1931 + if (item.is_show == 1) {
  1932 + check_all_cate = 1; break
  1933 + }
1934 1934 }
  1935 + }
1935 1936  
1936 1937 if (check_all_cate) {
1937 1938  
... ... @@ -1940,29 +1941,29 @@ Page({
1940 1941 var newarr = new Array();
1941 1942 var qita = new Array();
1942 1943  
1943   - var is_del_pk=0;
  1944 + var is_del_pk = 0;
1944 1945 //----要进行门店分组--------
1945 1946 for (var i = 0; i < sto_arr.length; i++) {
1946 1947 //找一下这个门店有没有在分类数组内
1947 1948 var find2 = 0, find2name = "", sort = 0;
1948   - is_del_pk=0;
  1949 + is_del_pk = 0;
1949 1950 for (var m = 0; m < sto_cate.length; m++) {
1950   - if (sto_arr[i].category_id == sto_cate[m].cat_id) {
1951   - if (sto_cate[m].is_show != 1) {
1952   - is_del_pk = 1;
1953   - sto_arr.splice(i, 1);
1954   - i--;
1955   - } else {
1956   - find2 = sto_cate[m].cat_id;
1957   - find2name = sto_cate[m].cat_name;
1958   - sort = sto_cate[m].sort;
1959   - is_del_pk = 0;
1960   - }
1961   - break;
  1951 + if (sto_arr[i].category_id == sto_cate[m].cat_id) {
  1952 + if (sto_cate[m].is_show != 1) {
  1953 + is_del_pk = 1;
  1954 + sto_arr.splice(i, 1);
  1955 + i--;
  1956 + } else {
  1957 + find2 = sto_cate[m].cat_id;
  1958 + find2name = sto_cate[m].cat_name;
  1959 + sort = sto_cate[m].sort;
  1960 + is_del_pk = 0;
1962 1961 }
  1962 + break;
  1963 + }
1963 1964 }
1964 1965  
1965   - if(is_del_pk) continue;
  1966 + if (is_del_pk) continue;
1966 1967  
1967 1968 if (newarr.length > 0) {
1968 1969 var find = 0;
... ... @@ -2008,17 +2009,17 @@ Page({
2008 2009 }
2009 2010  
2010 2011  
2011   - var def_arr = new Array();
2012   - //-- 开始就看10个门店 --
2013   - for (var k = 0; k < 10; k++) {
2014   - if (k == sto_arr.length) break;
2015   - def_arr.push(sto_arr[k]);
2016   - }
  2012 + var def_arr = new Array();
  2013 + //-- 开始就看10个门店 --
  2014 + for (var k = 0; k < 10; k++) {
  2015 + if (k == sto_arr.length) break;
  2016 + def_arr.push(sto_arr[k]);
  2017 + }
2017 2018  
2018   - th.setData({
2019   - def_pickpu_list: def_arr,
2020   - pickpu_list: ee.data.data.pageData
2021   - });
  2019 + th.setData({
  2020 + def_pickpu_list: def_arr,
  2021 + pickpu_list: ee.data.data.pageData
  2022 + });
2022 2023 //门店分类要排序下
2023 2024 function compare(property) {
2024 2025 return function (a, b) {
... ... @@ -2042,15 +2043,15 @@ Page({
2042 2043 }
2043 2044  
2044 2045  
2045   - var sd={
2046   - all_sto: newarr,
2047   - is_show_sto_cat:1
2048   - }
2049   - if(!sto_arr || sto_arr.length<=10){
2050   - sd.is_show_sto_cat=-1;
2051   - sd.only_pk=sto_arr;
2052   - }
2053   - th.setData(sd);
  2046 + var sd = {
  2047 + all_sto: newarr,
  2048 + is_show_sto_cat: 1
  2049 + }
  2050 + if (!sto_arr || sto_arr.length <= 10) {
  2051 + sd.is_show_sto_cat = -1;
  2052 + sd.only_pk = sto_arr;
  2053 + }
  2054 + th.setData(sd);
2054 2055  
2055 2056 } else {
2056 2057 th.setData({
... ... @@ -2399,21 +2400,21 @@ Page({
2399 2400 }
2400 2401 } else {
2401 2402  
2402   - //活动已结束,全部设置为'00'
2403   - obj = {
2404   - day: '00',
2405   - hou: '00',
2406   - min: '00',
2407   - sec: '00'
2408   - }
2409   - th.setData({
2410   - prom_time_text: '活动已经结束:',
2411   - prom_st: 3
2412   - })
2413   - th.setData({
2414   - djs: obj
2415   - });
2416   - return false;
  2403 + //活动已结束,全部设置为'00'
  2404 + obj = {
  2405 + day: '00',
  2406 + hou: '00',
  2407 + min: '00',
  2408 + sec: '00'
  2409 + }
  2410 + th.setData({
  2411 + prom_time_text: '活动已经结束:',
  2412 + prom_st: 3
  2413 + })
  2414 + th.setData({
  2415 + djs: obj
  2416 + });
  2417 + return false;
2417 2418  
2418 2419 }
2419 2420  
... ... @@ -2427,56 +2428,56 @@ Page({
2427 2428  
2428 2429  
2429 2430 //-------------获取购买数量的总函数----------------
2430   - get_buy_num: function (gd, func) {
2431   - var map = this.data.g_buy_num,
2432   - th = this,
2433   - user_id = getApp().globalData.user_id;
2434   - if (user_id == null) {
2435   - map.set(gd.goods_id, 0);
  2431 + get_buy_num: function (gd, func) {
  2432 + var map = this.data.g_buy_num,
  2433 + th = this,
  2434 + user_id = getApp().globalData.user_id;
  2435 + if (user_id == null) {
  2436 + map.set(gd.goods_id, 0);
  2437 + th.setData({
  2438 + g_buy_num: map,
  2439 + prom_buy_num: 0,
  2440 + });
  2441 + "function" == typeof func && func();
  2442 + return false;
  2443 + }
  2444 +
  2445 + if (map.has(gd.goods_id)) {
  2446 + "function" == typeof func && func();
  2447 + } else {
  2448 + //----获取商品购买数----
  2449 + getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", {
  2450 + data: {
  2451 + store_id: os.stoid,
  2452 + user_id: user_id,
  2453 + goods_id: gd.goods_id,
  2454 + },
  2455 + success: function (t) {
  2456 + if (t.data.code == 0) {
  2457 + var g_buy_num = t.data.data.goodsbuynum;
  2458 + map.set(gd.goods_id, g_buy_num);
2436 2459 th.setData({
2437   - g_buy_num: map,
2438   - prom_buy_num: 0,
  2460 + g_buy_num: map,
2439 2461 });
2440   - "function" == typeof func && func();
2441   - return false;
2442   - }
2443   -
2444   - if (map.has(gd.goods_id)) {
2445   - "function" == typeof func && func();
2446   - } else {
2447   - //----获取商品购买数----
2448   - getApp().request.get("/api/weshop/ordergoods/getUserBuyGoodsNum", {
2449   - data: {
2450   - store_id: os.stoid,
2451   - user_id: user_id,
2452   - goods_id: gd.goods_id,
2453   - },
2454   - success: function (t) {
2455   - if (t.data.code == 0) {
2456   - var g_buy_num = t.data.data.goodsbuynum;
2457   - map.set(gd.goods_id, g_buy_num);
2458   - th.setData({
2459   - g_buy_num: map,
2460   - });
2461   - getApp().request.get("/api/weshop/order/orderPresell/countBuyGoodsSum",{
2462   - data: {store_id: os.stoid, user_id: user_id, goods_id: gd.goods_id, prom_id: gd.prom_id},
2463   - success: function (e) {
2464   - if (e.data.code == 0) {
2465   - th.setData({prom_buy_num: e.data.data.sumgoodsnum})
2466   - "function" == typeof func && func();
2467   - } else {
2468   - th.setData({prom_buy_num: 0,})
2469   - "function" == typeof func && func();
2470   - }
2471   -
2472   - }
2473   - });
2474   -
2475   - }
  2462 + getApp().request.get("/api/weshop/order/orderPresell/countBuyGoodsSum", {
  2463 + data: { store_id: os.stoid, user_id: user_id, goods_id: gd.goods_id, prom_id: gd.prom_id },
  2464 + success: function (e) {
  2465 + if (e.data.code == 0) {
  2466 + th.setData({ prom_buy_num: e.data.data.sumgoodsnum })
  2467 + "function" == typeof func && func();
  2468 + } else {
  2469 + th.setData({ prom_buy_num: 0, })
  2470 + "function" == typeof func && func();
2476 2471 }
  2472 +
  2473 + }
2477 2474 });
  2475 +
  2476 + }
2478 2477 }
2479   - },
  2478 + });
  2479 + }
  2480 + },
2480 2481  
2481 2482 //--拼单推荐的显示---
2482 2483 tj_Click: function (e) {
... ... @@ -2488,7 +2489,7 @@ Page({
2488 2489  
2489 2490 //-------跳转pt商品-------
2490 2491 go_to_nopay: function () {
2491   - var th =this,url = "/pages/user/order_detail/order_detail?order_id=" + th.data.buy_order.order_id;
  2492 + var th = this, url = "/pages/user/order_detail/order_detail?order_id=" + th.data.buy_order.order_id;
2492 2493 getApp().goto(url);
2493 2494  
2494 2495 },
... ... @@ -2635,12 +2636,12 @@ Page({
2635 2636 //过滤不是本商品的单品优惠券
2636 2637 if (quan_list.length > 0) {
2637 2638 let goodInfo = th.data.data
2638   - for (let index = quan_list.length-1; index >= 0; index--) {
2639   - if (quan_list[index].useobjecttype==20) { //判断是单品优惠券
  2639 + for (let index = quan_list.length - 1; index >= 0; index--) {
  2640 + if (quan_list[index].useobjecttype == 20) { //判断是单品优惠券
2640 2641 if (quan_list[index].useobjectno != goodInfo.goods_sn) {
2641   - quan_list.splice(index,1)
  2642 + quan_list.splice(index, 1)
2642 2643 }
2643   - }
  2644 + }
2644 2645 }
2645 2646 }
2646 2647 //------------------------
... ... @@ -2740,7 +2741,13 @@ Page({
2740 2741 }
2741 2742 })
2742 2743 },
2743   -
  2744 + saveImageFn(){
  2745 + if(this.data.share_b_img){
  2746 + this.saveImageToPhotosAlbum()
  2747 + }else{
  2748 + this.saveImageToPhotosAlbumDef()
  2749 + }
  2750 + },
2744 2751 //--定义的保存图片方法,分享团---
2745 2752 saveImageToPhotosAlbum: function () {
2746 2753 //--先判断会员状态--
... ... @@ -3066,7 +3073,608 @@ Page({
3066 3073 }
3067 3074 });
3068 3075 },
  3076 + //--定义的保存图片方法,分享团---
  3077 + saveImageToPhotosAlbumDef: function () {
  3078 + //--先判断会员状态--
  3079 + var user_info = getApp().globalData.userInfo;
  3080 + if (user_info == null || user_info.mobile == undefined || user_info.mobile == "" || user_info.mobile == null) {
  3081 + //getApp().my_warnning("请先登录",0,this);
  3082 + wx.navigateTo({url: '/packageE/pages/togoin/togoin',})
  3083 + return false;
  3084 + }
  3085 +
  3086 + if (this.data.share_hidden) {
  3087 + this.setData({share_hidden: false,});
  3088 + };
  3089 +
  3090 + //类型 0普通商品 1秒杀商品 2商家和会员团 3阶梯团 4阶梯团
  3091 + var type = this.data.prom_type;
  3092 + console.log('商品类型-----');
  3093 + console.log(type);
  3094 + // if (type == 2) type = -1;
  3095 + if (type == 4) type = 0;
  3096 + if (type == 8) type = 0;
  3097 + if (type == 2) type = 0;
  3098 + if (type == 6) type = 2; // 6拼团 2团购
  3099 + if (type == 10) type = -1;
  3100 +
  3101 +
  3102 + if (this.data.prom_act && this.data.prom_act.kttype == 3) type = 3;
  3103 + console.log('商品类型。。。。。');
  3104 + console.log(type);
  3105 + wx.showLoading({title: '生成中...',})
  3106 + var that = this, th = that;
  3107 + //设置画板显示,才能开始绘图
  3108 + that.setData({
  3109 + canvasHidden: false
  3110 + })
  3111 +
  3112 + var app = getApp();
  3113 + var unit = that.data.screenWidth / 750 * 1.35; //基础单位,
  3114 + var path2 = that.data.data.original_img;
  3115 + var scene = th.data.gid + "";
  3116 + scene += "." + th.data.sele_g.prom_type + "." + th.data.sele_g.prom_id;
  3117 +
  3118 + var user_id = getApp().globalData.user_id ? getApp().globalData.user_id : 0;
  3119 + if (user_id > 0) {
  3120 + scene += "_" + user_id;
  3121 + }
  3122 + //-- 如果不是会员分享过来的要分享给别人 --
  3123 + if (getApp().globalData.room_id && th.data.data.goods_id == getApp().globalData.room_goods_id && !getApp().globalData.room_user_share) {
  3124 + //固定房间是第3个字符
  3125 + if (!user_id) scene += "_0";
  3126 + scene += "_" + getApp().globalData.room_id;
  3127 + }
  3128 +
  3129 + ///二微码
  3130 + var path3 = os.url + "/api/wx/open/app/user/getWeAppEwm/" +
  3131 + os.stoid + "?sceneValue=" + scene + "&pageValue=packageC/pages/presell/goodsInfo/goodsInfo";
  3132 +
  3133 + console.log(path3);
  3134 +
  3135 +
  3136 + // 读取文件成功则OK--
  3137 + wx.getImageInfo({
  3138 + src: path3,
  3139 + success: function (res) {
  3140 + // 回调写法
  3141 + th.get_head_temp(th.get_goods_temp, function () {
  3142 + var vpath = res.path;
  3143 + var context = wx.createCanvasContext('share');
  3144 + // 先画背景
  3145 + var pg_path = "../../../../images/share/share_bg.png";
  3146 +
3069 3147  
  3148 + //-- 如果有自定义海报的时候,判断背景的图片 --
  3149 + if (th.data.share_b_img) {
  3150 + pg_path = th.data.share_b_img;
  3151 + }
  3152 + // context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit);
  3153 + console.log('海报类型-----')
  3154 + console.log(type);
  3155 +
  3156 + if ( !th.data.share_b_img && (type == 0 || type == 1 || type == 2 || type == 3 )){ // 如果是普通商品,绘制新海报
  3157 + th.drawPoster(context, unit, th.data.share_goods_img, vpath, type);
  3158 + } else {
  3159 + context.drawImage(pg_path, 0, 0, 554 * unit, 899 * unit);
  3160 + // var erm_x = parseFloat(th.data.poster.ewm_x) * 2;
  3161 + // var erm_y = parseFloat(th.data.poster.ewm_y) * 2;
  3162 + // context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit);
  3163 + // th.drawPoster(context, unit, th.data.share_goods_img, vpath);
  3164 + };
  3165 +
  3166 + // th.drawPoster(context, unit, th.data.share_goods_img, vpath);
  3167 +
  3168 +
  3169 + //-- 是自定义海报的情况下 --
  3170 + if (th.data.share_b_img || (type != 0 && type != 1 && type != 2 && type != 3)) {
  3171 +
  3172 + if (th.data.poster && parseInt(th.data.poster.style) == 2) {
  3173 + //在线上分享人的情况下
  3174 + if (parseInt(th.data.poster.show_headpic)) {
  3175 + //获取坐标
  3176 + var x = parseFloat(th.data.poster.head_x) * 2;
  3177 + var y = parseFloat(th.data.poster.head_y) * 2;
  3178 + var x1 = (x + 90) * unit;
  3179 + var y1 = (y + 50) * unit;
  3180 + //--昵称---
  3181 + context.setFontSize(24 * unit)
  3182 + context.setFillStyle("black")
  3183 + context.fillText(app.globalData.userInfo.nickname, x1, y1);
  3184 + var width = 24 * app.globalData.userInfo.nickname.length * unit + 4 * unit;
  3185 + //强烈推荐 改许程
  3186 + var tj_path = "../../../../images/share/q_tj.png";
  3187 + context.drawImage(tj_path, x1 + width, y1 - 22 * unit, 85 * unit, 30 * unit);
  3188 + context.setFontSize(16 * unit);
  3189 + context.setLineJoin('round'); //交点设置成圆角
  3190 + context.setFillStyle("white");
  3191 + context.fillText('强烈推荐', x1 + width + 8 * unit, y1 - 1 * unit);
  3192 +
  3193 + //context.setFillStyle("black")
  3194 + //context.setFontSize(24 * unit)
  3195 + //context.fillText(getApp().globalData.config.store_name, 40 * unit, 130 * unit);
  3196 + }
  3197 + } else {
  3198 + //--昵称---
  3199 + context.setFontSize(24 * unit);
  3200 + context.setFillStyle("black");
  3201 + context.fillText(app.globalData.userInfo.nickname, 152 * unit, 76 * unit);
  3202 + var width = 24 * app.globalData.userInfo.nickname.length * unit + 2 * unit;
  3203 + //强烈推荐 改许程
  3204 + var tj_path = "../../../../images/share/q_tj.png";
  3205 + context.drawImage(tj_path, 152 * unit + width, 54 * unit, 85 * unit, 30 * unit);
  3206 + context.setFontSize(16 * unit);
  3207 + context.setLineJoin('round'); //交点设置成圆角
  3208 + context.setFillStyle("white");
  3209 + context.fillText('强烈推荐', 149 * unit + width + 15 * unit, 75 * unit);
  3210 + }
  3211 +
  3212 + };
  3213 +
  3214 +
  3215 + var share_title = th.data.data.goods_name;
  3216 + if (th.data.prom_type == 1 || th.data.prom_type == 2 || th.data.prom_type == 6 || th.data.prom_type == 4) {
  3217 + share_title = th.data.prom_act.share_title;
  3218 + if (!share_title) share_title = th.data.prom_act.title;
  3219 + if (th.data.prom_type == 4) share_title = th.data.prom_act.name;
  3220 + }
  3221 +
  3222 + //---产品名称---
  3223 + //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度
  3224 + if (th.data.share_b_img || (type != 4 && type != 0 && type != 1 && type != 2 && type != 3)) {
  3225 + context.setFillStyle("black");
  3226 + context.setFontSize(21.3 * unit)
  3227 + getApp().draw_Text(context, share_title,
  3228 + 38 * unit, 180 * unit, 200 * unit, 279 * unit, unit);
  3229 +
  3230 + //------产品的价格-------
  3231 + context.setFontSize(23 * unit)
  3232 + context.setFillStyle("red")
  3233 +
  3234 + var pri0 = th.data.data.shop_price;
  3235 + if (th.data.card_field && th.data.data[th.data.card_field]) {
  3236 + pri0 = th.data.data[th.data.card_field];
  3237 + }
  3238 +
  3239 + if (th.data.prom_act)
  3240 + pri0 = th.data.prom_price;
  3241 + pri0 = parseFloat(pri0).toFixed(2);
  3242 + var wd1 = th.data.screenWidth - ut.measureText(pri0, 31 * unit) - 25;
  3243 + context.fillText("¥", wd1 - 15, 185 * unit);
  3244 + context.setFontSize(31 * unit)
  3245 + context.fillText(pri0, wd1, 185 * unit);
  3246 +
  3247 + //---市场价划掉---
  3248 + /*--
  3249 + context.setFillStyle("gray")
  3250 + context.setFontSize(22 * unit)
  3251 + pri0 = "¥" + th.data.data.market_price.toFixed(2);
  3252 + var wd2 = th.data.screenWidth - ut.measureText(pri0, 22 * unit) - 25;
  3253 + context.fillText(pri0, wd2, 213 * unit);
  3254 +
  3255 + context.setStrokeStyle('gray');
  3256 + context.setLineWidth(1 * unit);
  3257 + context.moveTo(wd2 - 5, 206 * unit);
  3258 + context.lineTo(wd2 + ut.measureText(pri0, 22 * unit) + 5, 206 * unit);
  3259 + context.stroke();--*/
  3260 +
  3261 + } else if ( ( type == 4 && type != 0 && type != 1 && type != 2 && type != 3)) {
  3262 + context.setFillStyle("black");
  3263 + context.setFontSize(21.3 * unit)
  3264 + getApp().draw_Text(context, share_title,
  3265 + 38 * unit, 170 * unit, 20 * unit, 300 * unit, unit);
  3266 + //------ 产品的价格 -----
  3267 + var pri0 = th.data.prom_act.addmoney;
  3268 + var integral = th.data.prom_act.integral;
  3269 + var text = "";
  3270 + if (integral) {
  3271 + text = integral + "积分";
  3272 + }
  3273 + if (pri0 && integral) {
  3274 + text += "+";
  3275 + }
  3276 + if (pri0) {
  3277 + text += "¥" + pri0;
  3278 + }
  3279 +
  3280 + if (!pri0 && !integral) {
  3281 + text = "0积分";
  3282 + }
  3283 + context.setFillStyle("red");
  3284 + context.fillText(text, 38 * unit, 235 * unit);
  3285 +
  3286 + }
  3287 +
  3288 + //---中间大图---
  3289 + if ( th.data.share_b_img || (type != 0 && type != 1 && type != 2 && type != 3)) {
  3290 + context.drawImage(th.data.share_goods_img, 70 * unit, 250 * unit, 408 * unit, 408 * unit);
  3291 + }
  3292 + ;
  3293 +
  3294 + //---自定义海报 产品质量保证
  3295 + if(th.data.share_b_img && th.data.poster.show_quality==1 ){
  3296 + var g_path = "../../../../images/share/s_gou.png";
  3297 + context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit);
  3298 + context.setFillStyle("red")
  3299 + context.setFontSize(18 * unit)
  3300 + context.fillText("正品保证", 84 * unit, 690 * unit);
  3301 +
  3302 + context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit);
  3303 + context.setFillStyle("red")
  3304 + context.setFontSize(18 * unit)
  3305 + context.fillText("纯实体店", 246 * unit, 690 * unit);
  3306 +
  3307 + context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit);
  3308 + context.setFillStyle("red")
  3309 + context.setFontSize(18 * unit)
  3310 + context.fillText("官方验证", 420 * unit, 690 * unit);
  3311 +
  3312 + }
  3313 + //-------大图后面就不一样了-----------
  3314 + switch (type) {
  3315 + case 0:
  3316 + if(!th.data.share_b_img){
  3317 + break
  3318 + }
  3319 + //---画线---
  3320 + context.setLineWidth(1 * unit)
  3321 + context.moveTo(32 * unit, 710 * unit)
  3322 + context.lineTo(520 * unit, 710 * unit)
  3323 + context.stroke();
  3324 + //---文字---
  3325 + context.setFillStyle("black")
  3326 + context.setFontSize(22 * unit)
  3327 + // 原来start --->
  3328 + context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 776 * unit);
  3329 + context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 826 * unit);
  3330 + // <--- 原来end
  3331 + // context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 816 * unit);
  3332 + // context.setFontSize(18 * unit)
  3333 + // context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 850 * unit);
  3334 + //---二维吗图---
  3335 + context.drawImage(vpath, 380 * unit, 736 * unit, 120 * unit, 120 * unit);
  3336 + break;//普通商品的展示
  3337 + case 4:
  3338 + // 中间的几个字
  3339 + if (th.data.poster && parseInt(th.data.poster.style) == 2) {
  3340 + if (parseInt(th.data.poster.show_quality)) {
  3341 + var g_path = "../../../../images/share/s_gou.png";
  3342 + context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit);
  3343 + context.setFillStyle("red")
  3344 + context.setFontSize(18 * unit)
  3345 + context.fillText("正品保证", 84 * unit, 690 * unit);
  3346 +
  3347 + context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit);
  3348 + context.setFillStyle("red")
  3349 + context.setFontSize(18 * unit)
  3350 + context.fillText("纯实体店", 246 * unit, 690 * unit);
  3351 +
  3352 + context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit);
  3353 + context.setFillStyle("red")
  3354 + context.setFontSize(18 * unit)
  3355 + context.fillText("官方验证", 420 * unit, 690 * unit);
  3356 + }
  3357 +
  3358 + } else {
  3359 + var g_path = "../../../../images/share/s_gou.png";
  3360 + context.drawImage(g_path, 56 * unit, 670 * unit, 22 * unit, 22 * unit);
  3361 + context.setFillStyle("red")
  3362 + context.setFontSize(18 * unit)
  3363 + context.fillText("正品保证", 84 * unit, 690 * unit);
  3364 +
  3365 + context.drawImage(g_path, 218 * unit, 670 * unit, 22 * unit, 22 * unit);
  3366 + context.setFillStyle("red")
  3367 + context.setFontSize(18 * unit)
  3368 + context.fillText("纯实体店", 246 * unit, 690 * unit);
  3369 +
  3370 + context.drawImage(g_path, 388 * unit, 670 * unit, 22 * unit, 22 * unit);
  3371 + context.setFillStyle("red")
  3372 + context.setFontSize(18 * unit)
  3373 + context.fillText("官方验证", 420 * unit, 690 * unit);
  3374 + }
  3375 +
  3376 +
  3377 + //---画线---
  3378 + context.setLineWidth(1 * unit)
  3379 + context.moveTo(32 * unit, 710 * unit)
  3380 + context.lineTo(520 * unit, 710 * unit)
  3381 + context.stroke();
  3382 +
  3383 + //---文字---
  3384 + context.setFillStyle("black")
  3385 + context.setFontSize(22 * unit)
  3386 +
  3387 + if (type == 0 || type == -1) {
  3388 + // 原来start --->
  3389 + context.setFontSize(24 * unit)
  3390 + context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit);
  3391 +
  3392 + context.setFontSize(22 * unit)
  3393 + context.fillText("优惠乐翻天,精彩就在你身边", 40 * unit, 806 * unit);
  3394 + context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 846 * unit);
  3395 +
  3396 + } else {
  3397 + context.setFontSize(24 * unit)
  3398 + context.fillText(th.data.sto_sele_name_1, 40 * unit, 766 * unit);
  3399 + context.setFontSize(22 * unit)
  3400 + context.fillText("长按识别二维码", 40 * unit, 806 * unit);
  3401 + context.fillText("立即开始兑换", 40 * unit, 846 * unit);
  3402 +
  3403 + }
  3404 +
  3405 + //---二维吗图---
  3406 + //-- 自定义海报 --
  3407 + if (th.data.share_b_img || th.data.poster) {
  3408 + var erm_x = parseFloat(th.data.poster.ewm_x) * 2;
  3409 + var erm_y = parseFloat(th.data.poster.ewm_y) * 2;
  3410 + context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit);
  3411 + } else {
  3412 + //---二维吗图---
  3413 + context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit);
  3414 + }
  3415 + ;
  3416 +
  3417 + break;
  3418 + case 1: //秒杀商品的展示
  3419 + if(!th.data.share_b_img){
  3420 + break
  3421 + }
  3422 + //---画线---
  3423 + context.setLineWidth(1 * unit)
  3424 + context.moveTo(32 * unit, 670 * unit)
  3425 + context.lineTo(520 * unit, 670 * unit)
  3426 + context.stroke();
  3427 +
  3428 + //画秒杀的图片
  3429 + var miaos_path = '../../../../images/share/miao_share.png';
  3430 + context.drawImage(miaos_path, 43 * unit, 700 * unit, 222 * unit, 40 * unit);
  3431 +
  3432 + context.setFillStyle("black")
  3433 + context.setFontSize(24 * unit)
  3434 + context.fillText(th.data.sto_sele_name_1, 40 * unit, 786 * unit);
  3435 + //---文字---
  3436 + context.setFontSize(22 * unit)
  3437 + context.setFillStyle("black")
  3438 + context.fillText("特惠好物,限时秒杀", 40 * unit, 826 * unit);
  3439 + context.fillText("长按识别二维码,立即开始抢购", 40 * unit, 866 * unit);
  3440 +
  3441 +
  3442 + //---二维吗图---
  3443 + //-- 自定义海报 --
  3444 + if (th.data.share_b_img || th.data.poster) {
  3445 + var erm_x = parseFloat(th.data.poster.ewm_x) * 2;
  3446 + var erm_y = parseFloat(th.data.poster.ewm_y) * 2;
  3447 + context.drawImage(vpath, erm_x * unit, erm_y * unit, 135 * unit, 135 * unit);
  3448 + } else {
  3449 + //---二维吗图---
  3450 + context.drawImage(vpath, 390 * unit, 726 * unit, 135 * unit, 135 * unit);
  3451 + }
  3452 + break;
  3453 +
  3454 + case 2: //会员团和商家团的展示
  3455 + if(!th.data.share_b_img){
  3456 + break
  3457 + }
  3458 + //---画线---
  3459 + context.setLineWidth(1 * unit)
  3460 + context.moveTo(32 * unit, 670 * unit)
  3461 + context.lineTo(520 * unit, 670 * unit)
  3462 + context.stroke();
  3463 + //---文字---
  3464 + context.setFillStyle("black")
  3465 + context.setFontSize(24 * unit)
  3466 + context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit);
  3467 +
  3468 + //绘制成团图片
  3469 + var ct_img = "../../../../images/share/ct_num.png";
  3470 + context.drawImage(ct_img, 40 * unit, 740 * unit, 120 * unit, 30 * unit);
  3471 + var ct_num = th.data.prom_act.ct_num;
  3472 + context.setFontSize(14 * unit)
  3473 + context.font = 'normal';
  3474 + context.setFillStyle("red")
  3475 + if (ct_num < 10) {
  3476 + context.fillText(ct_num + "人拼团", 92 * unit, 760 * unit);
  3477 + } else {
  3478 + context.fillText(ct_num + "人拼团", 86 * unit, 760 * unit);
  3479 + }
  3480 + context.setFontSize(22 * unit)
  3481 + context.fillText("已拼" + th.data.prom_act.buy_num + "份", 166 * unit, 763 * unit);
  3482 +
  3483 + context.setFillStyle("gray")
  3484 + context.fillText("快来和我一起拼团吧!", 40 * unit, 806 * unit);
  3485 + context.setFillStyle("black")
  3486 + context.font = 'normal bold 18px sans-serif';
  3487 + context.setFontSize(21.3 * unit)
  3488 + context.fillText("长按识别二维码,立即参团", 40 * unit, 836 * unit);
  3489 +
  3490 +
  3491 + //---二维吗图---
  3492 + //-- 自定义海报 --
  3493 + if (th.data.share_b_img || th.data.poster) {
  3494 + var erm_x = parseFloat(th.data.poster.ewm_x) * 2;
  3495 + var erm_y = parseFloat(th.data.poster.ewm_y) * 2;
  3496 + context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit);
  3497 + } else {
  3498 + //---二维吗图---
  3499 + context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit);
  3500 + }
  3501 + break
  3502 + case 3: //阶梯团的展示
  3503 + if(!th.data.share_b_img){
  3504 + break
  3505 + }
  3506 + //---画线---
  3507 + context.setLineWidth(1 * unit)
  3508 + context.moveTo(32 * unit, 670 * unit)
  3509 + context.lineTo(520 * unit, 670 * unit)
  3510 + context.stroke();
  3511 + //---文字---
  3512 + context.setFillStyle("black")
  3513 + context.setFontSize(24 * unit)
  3514 + context.fillText(th.data.sto_sele_name_1, 40 * unit, 720 * unit);
  3515 +
  3516 + //---绘制中间阶梯的价格---
  3517 + var list = th.data.prom_act.ct_rylist;
  3518 + for (var i = 0; i < list.length; i++) {
  3519 + var item = list[i];
  3520 + var wi = i * 90 * unit;
  3521 + context.font = 'normal';
  3522 + context.setFontSize(16 * unit)
  3523 + context.setFillStyle("red")
  3524 + context.fillText("¥", 40 * unit + wi, 756 * unit);
  3525 + context.setFontSize(22 * unit)
  3526 + var pri = parseFloat(item.price).toFixed(2);
  3527 + context.fillText(pri, 56 * unit + wi, 756 * unit);
  3528 + context.setFillStyle("gray")
  3529 + context.fillText("满" + item.rynum + "人", 40 * unit + wi, 786 * unit);
  3530 + }
  3531 + //----------------下面部分----------------
  3532 +
  3533 + context.setFillStyle("black")
  3534 + context.fillText("快来和我一起拼团吧!", 40 * unit, 820 * unit);
  3535 + //context.font = 'normal bold 18px sans-serif';
  3536 + context.setFontSize(21 * unit)
  3537 + context.fillText("长按识别二维码,立即参团", 40 * unit, 850 * unit);
  3538 +
  3539 +
  3540 + //-- 自定义海报 --
  3541 + if (th.data.share_b_img || th.data.poster) {
  3542 + var erm_x = parseFloat(th.data.poster.ewm_x) * 2;
  3543 + var erm_y = parseFloat(th.data.poster.ewm_y) * 2;
  3544 + context.drawImage(vpath, erm_x * unit, erm_y * unit, 136 * unit, 136 * unit);
  3545 + } else {
  3546 + //---二维吗图---
  3547 + context.drawImage(vpath, 390 * unit, 726 * unit, 136 * unit, 136 * unit);
  3548 + }
  3549 + break
  3550 +
  3551 +
  3552 + case -1: //秒杀商品的展示
  3553 + //---画线---
  3554 + context.setLineWidth(1 * unit)
  3555 + context.moveTo(32 * unit, 670 * unit)
  3556 + context.lineTo(520 * unit, 670 * unit)
  3557 + context.stroke();
  3558 +
  3559 +
  3560 + context.setFillStyle("black")
  3561 + context.setFontSize(24 * unit)
  3562 + context.fillText(th.data.sto_sele_name_1, 40 * unit, 744 * unit);
  3563 + //---文字---
  3564 + context.setFontSize(22 * unit)
  3565 + context.setFillStyle("black")
  3566 + context.fillText("长按识别二维码", 40 * unit, 800 * unit);
  3567 + context.fillText("立即开始抢购", 40 * unit, 846 * unit);
  3568 +
  3569 +
  3570 + //---二维吗图---
  3571 + //-- 自定义海报 --
  3572 + if (th.data.share_b_img || th.data.poster) {
  3573 + var erm_x = parseFloat(th.data.poster.ewm_x) * 2;
  3574 + var erm_y = parseFloat(th.data.poster.ewm_y) * 2;
  3575 + context.drawImage(vpath, erm_x * unit, erm_y * unit, 135 * unit, 135 * unit);
  3576 + } else {
  3577 + //---二维吗图---
  3578 + context.drawImage(vpath, 390 * unit, 726 * unit, 135 * unit, 135 * unit);
  3579 + }
  3580 + break;
  3581 +
  3582 +
  3583 + }
  3584 +
  3585 +
  3586 + //--- 如果是自定义海报的时候 ---
  3587 + if ( th.data.share_b_img || (type != 0 && type != 1 && type != 2 && type != 3)) {
  3588 +
  3589 + if (th.data.poster && parseInt(th.data.poster.style) == 2) {
  3590 +
  3591 + //如果显示会员信息的话
  3592 + if (parseInt(th.data.poster.show_headpic)) {
  3593 + //获取坐标
  3594 + var x = parseFloat(th.data.poster.head_x) * 2;
  3595 + var y = parseFloat(th.data.poster.head_y) * 2;
  3596 + //---绘制圆形要放在最后----
  3597 + context.save();
  3598 + context.beginPath();
  3599 + var h_x = x * unit;
  3600 + var h_y = y * unit;
  3601 + var h_r = 40 * unit;
  3602 + var cx = h_x + h_r;
  3603 + var cy = h_y + h_r;
  3604 + context.arc(cx, cy, h_r, 0, Math.PI * 2, false);
  3605 + context.closePath();
  3606 + context.fill();
  3607 + context.clip();
  3608 + context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2);
  3609 + context.restore();
  3610 + }
  3611 +
  3612 + } else {
  3613 + //---绘制圆形要放在最后----
  3614 + context.save();
  3615 + context.beginPath();
  3616 + var h_x = 60 * unit;
  3617 + var h_y = 24 * unit;
  3618 + var h_r = 40 * unit;
  3619 + var cx = h_x + h_r;
  3620 + var cy = h_y + h_r;
  3621 + context.arc(cx, cy, h_r, 0, Math.PI * 2, false);
  3622 + context.closePath();
  3623 + context.fill();
  3624 + context.clip();
  3625 + context.drawImage(th.data.share_head, h_x, h_y, h_r * 2, h_r * 2);
  3626 + context.restore();
  3627 + }
  3628 +
  3629 + }
  3630 + ;
  3631 +
  3632 +
  3633 + //把画板内容绘制成图片,并回调 画板图片路径
  3634 + context.draw(false, function () {
  3635 + setTimeout(function () {
  3636 + wx.canvasToTempFilePath({
  3637 + x: 0,
  3638 + y: 0,
  3639 + width: 750,
  3640 + height: 1217,
  3641 + destWidth: 1.2 * 750 * 750 / that.data.screenWidth,
  3642 + destHeight: 1.2 * 1217 * 750 / that.data.screenWidth,
  3643 + canvasId: 'share',
  3644 + success: function (res) {
  3645 +
  3646 + that.setData({
  3647 + shareImgPath: res.tempFilePath,
  3648 + canvasHidden: true
  3649 + })
  3650 +
  3651 + if (!res.tempFilePath) {
  3652 + wx.showModal({
  3653 + title: '提示',
  3654 + content: '图片绘制中,请稍后重试',
  3655 + showCancel: false
  3656 + })
  3657 + return false;
  3658 + }
  3659 +
  3660 + that.setData({
  3661 + showPoster: true,
  3662 + });
  3663 + wx.hideLoading();
  3664 + }
  3665 + })
  3666 + }, 500)
  3667 +
  3668 + });
  3669 + });
  3670 + },
  3671 + fail: function (res) {
  3672 + console.log(res);
  3673 + wx.hideLoading();
  3674 +
  3675 + }
  3676 + });
  3677 + },
3070 3678  
3071 3679 //文本换行 参数:1、canvas对象,2、文本 3、距离左侧的距离 4、距离顶部的距离 5、6、文本的宽度
3072 3680 draw_Text: function (ctx, str, leftWidth, initHeight, titleHeight, canvasWidth, unit) {
... ... @@ -3095,7 +3703,144 @@ Page({
3095 3703 }
3096 3704 }
3097 3705 },
  3706 + drawPoster(context, unit, img, vpath, type) {
  3707 + // 1.灰色背景
  3708 + context.setFillStyle('#f2f1f6');
  3709 + context.rect(0, 0, 554 * unit, 899 * unit);
  3710 + context.fill();
  3711 +
  3712 + // 2.商城名称
  3713 + let shopName = this.data.sto_sele_name_1;
  3714 + context.setTextAlign('center');
  3715 + context.setFontSize(26 * unit);
  3716 + context.setFillStyle('black');
  3717 + context.fillText(shopName, 277 * unit, 60 * unit);
  3718 +
  3719 + // 3.推荐来源
  3720 + let fromText = `来自${getApp().globalData.userInfo.nickname}的推荐`;
  3721 + context.setTextAlign('center');
  3722 + context.setFontSize(22 * unit);
  3723 + context.setFillStyle('#96959a');
  3724 + context.fillText(fromText, 277 * unit, 105 * unit);
  3725 +
  3726 + // 4.海报背景
  3727 + context.setFillStyle('white');
  3728 + context.fillRect(37 * unit, 157 * unit, 480 * unit, 673 * unit);
  3729 +
  3730 + // 5.商品图片
  3731 + // 图片的x坐标
  3732 + let bg_x = 37 * unit
  3733 + // 图片的y坐标
  3734 + let bg_y = 157 * unit
  3735 + // 图片宽度
  3736 + let bg_w = 480 * unit
  3737 + // 图片高度
  3738 + let bg_h = 474 * unit
  3739 + // 图片圆角
  3740 + let bg_r = 4
  3741 + // 绘制海报背景图片圆角
  3742 + context.save()
  3743 + context.beginPath()
  3744 + context.arc(bg_x + bg_r, bg_y + bg_r, bg_r, Math.PI, Math.PI * 1.5)
  3745 + context.arc(bg_x + bg_w - bg_r, bg_y + bg_r, bg_r, Math.PI * 1.5, Math.PI * 2)
  3746 + context.arc(bg_x + bg_w, bg_y + bg_h, bg_r, 0, Math.PI * 0.5)
  3747 + context.arc(bg_x, bg_y + bg_h, 0, Math.PI * 0.5, Math.PI)
  3748 + context.clip()
  3749 + context.drawImage(img, bg_x, bg_y, bg_w, bg_h);
  3750 + context.restore();
  3751 +
  3752 + // 6.强烈推荐
  3753 + let src = '';
  3754 + context.beginPath();
  3755 + if(type == 0) { // 普通
  3756 + src = '../../../../images/share/q_tj.png';
  3757 + context.drawImage(src, 54 * unit, 648 * unit, 85 * unit, 30 * unit);
  3758 + context.setFontSize(16 * unit)
  3759 + context.setFillStyle("white")
  3760 + context.setTextAlign('left');
  3761 + context.fillText('强烈推荐', 64 * unit, 668 * unit);
  3762 + };
  3763 + if(type == 1) { // 秒杀
  3764 + src = '../../../images/share/miao_share.png';
  3765 + context.drawImage(src, 54 * unit, 648 * unit, 200 * unit, 36 * unit);
  3766 + context.setTextAlign('left');
  3767 + };
  3768 + if(type == 2) { // 商家和会员团
  3769 + src = '../../../images/share/ct_num.png';
  3770 + context.drawImage(src, 54 * unit, 648 * unit, 120 * unit, 30 * unit);
  3771 + context.setTextAlign('left');
  3772 +
  3773 + let ct_num = self.data.prom_act.ct_num;
  3774 + context.setFontSize(16 * unit)
  3775 + context.font = 'normal';
  3776 + context.setFillStyle("red")
  3777 + if (ct_num < 10) {
  3778 + context.fillText(ct_num + "人拼团", 100 * unit, 670 * unit);
  3779 + } else {
  3780 + context.fillText(ct_num + "人拼团", 96 * unit, 670 * unit);
  3781 + }
  3782 + context.setFontSize(22 * unit)
  3783 + context.fillText("已拼" + self.data.prom_act.buy_num + "份", 186 * unit, 672 * unit);
  3784 + };
  3785 + if(type == 3) { // 阶梯团
  3786 + let list = self.data.prom_act.ct_rylist;
  3787 + for (let i = 0; i < list.length; i++) {
  3788 + let item = list[i];
  3789 + let wi = i * 90 * unit;
  3790 + context.font = 'normal';
  3791 + context.setTextAlign('left');
  3792 + context.setFontSize(16 * unit)
  3793 + context.setFillStyle("red")
  3794 + context.fillText("¥", 50 * unit + wi, 680 * unit);
  3795 + context.setFontSize(22 * unit)
  3796 + let pri = parseFloat(item.price).toFixed(2);
  3797 + context.fillText(pri, 66 * unit + wi, 680 * unit);
  3798 + context.setFillStyle("gray")
  3799 + context.fillText("满" + item.rynum + "人", 50 * unit + wi, 716 * unit);
  3800 + }
  3801 + };
  3802 +
  3803 + // 7.商品价格
  3804 + if(type != 3) {
  3805 + let price = this.data.data.shop_price;
  3806 + if (this.data.card_field && this.data.data[this.data.card_field]) {
  3807 + price = this.data.data[this.data.card_field];
  3808 + }
  3809 + if (this.data.prom_act) price = this.data.prom_price;
  3810 + price = parseFloat(price).toFixed(2);
  3811 + context.setFontSize(32 * unit);
  3812 + context.setFillStyle('#DE1117');
  3813 + if (this.data.prom_type == 4 && this.data.prom_integral){
  3814 + context.fillText(this.data.prom_integral+'积分+¥' + price, 54 * unit, 735 * unit);
  3815 + }else{
  3816 + if(this.data.prom_type ==8){
  3817 + price = this.data.presellList.presell_price
  3818 + context.fillText('¥' + price, 54 * unit, 735 * unit);
  3819 + }else{
  3820 + context.fillText('¥' + price, 54 * unit, 735 * unit);
  3821 + }
  3822 + }
  3823 +
3098 3824  
  3825 + };
  3826 +
  3827 + // 8.商品标题
  3828 + context.setFontSize(20 * unit);
  3829 + context.setFillStyle('#898989');
  3830 + getApp().draw_Text(context, this.data.data.goods_name, 54 * unit, 800 * unit, 240 * unit, 280 * unit, unit, 1);
  3831 +
  3832 + // 9.小程序码
  3833 + context.drawImage(vpath, 375 * unit, 660 * unit, 120 * unit, 120 * unit);
  3834 + context.setFontSize(16 * unit);
  3835 + context.setFillStyle('#777');
  3836 + context.fillText('长按识别二维码', 378 * unit, 810 * unit);
  3837 +
  3838 + // 10.竖线
  3839 + context.beginPath();
  3840 + context.setFillStyle('#eee');
  3841 + context.rect(354 * unit, 670 * unit, 1 * unit, 130 * unit);
  3842 + context.fill();
  3843 + },
3099 3844 // ----视频图片----
3100 3845 // 图片计数器
3101 3846 swiperChange: function (e) {
... ... @@ -3181,7 +3926,7 @@ Page({
3181 3926 tt();
3182 3927 return false;
3183 3928 }
3184   - var img_url = ee.data.data.original_img;
  3929 + var img_url = ee.data.data.original_img;
3185 3930 //var img_url = ee.data.presellForm.share_img;
3186 3931 //img_url?img_url:ee.data.data.original_img;
3187 3932  
... ... @@ -3196,8 +3941,8 @@ Page({
3196 3941 fail: function (res) {
3197 3942 //获取默认空白图
3198 3943 wx.getImageInfo({
3199   - src: ee.data.iurl+'/miniapp/images/default_g_img.gif',
3200   - success: function(res) {
  3944 + src: ee.data.iurl + '/miniapp/images/default_g_img.gif',
  3945 + success: function (res) {
3201 3946 ee.data.share_goods_img = res.path; //分享的图片不能用网络的
3202 3947 tt();
3203 3948 }
... ... @@ -3241,22 +3986,22 @@ Page({
3241 3986 getHistoryBuy() {
3242 3987 let _this = this;
3243 3988 let req_data = {
3244   - store_id: os.stoid,
3245   - goods_id: this.data.gid,
3246   - pay_status: 1,
3247   - rndid: 1
  3989 + store_id: os.stoid,
  3990 + goods_id: this.data.gid,
  3991 + pay_status: 1,
  3992 + rndid: 1
3248 3993 };
3249 3994 getApp().request.promiseGet('/api/weshop/ordergoods/list', {
3250   - data: req_data,
  3995 + data: req_data,
3251 3996 })
3252   - .then(res => {
3253   - if (ut.ajax_ok(res)) {
3254   - _this.setData({
3255   - historyBuyInfo: res.data.data.pageData,
3256   - })
3257   - }
3258   - })
3259   -},
  3997 + .then(res => {
  3998 + if (ut.ajax_ok(res)) {
  3999 + _this.setData({
  4000 + historyBuyInfo: res.data.data.pageData,
  4001 + })
  4002 + }
  4003 + })
  4004 + },
3260 4005  
3261 4006 //--调用更新阶梯团的接口--
3262 4007 update_jiti: function (id) {
... ... @@ -3284,8 +4029,8 @@ Page({
3284 4029 var bconfig = th.data.bconfig;
3285 4030  
3286 4031 //如果开启了,则不在选择门店
3287   - if(this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store){
3288   - return false;
  4032 + if (this.data.sys_switch.is_pricing_open_store && getApp().globalData.pk_store) {
  4033 + return false;
3289 4034 }
3290 4035  
3291 4036 if (!th.data.only_pk && !th.data.def_pickpu_list) {
... ... @@ -3909,7 +4654,7 @@ Page({
3909 4654  
3910 4655  
3911 4656 onShareTimeline() {
3912   - getApp().globalData.no_clear=1;
  4657 + getApp().globalData.no_clear = 1;
3913 4658 var store_name = getApp().globalData.config ? getApp().globalData.config.store_name : '';
3914 4659 if (!store_name)
3915 4660 store_name = getApp().globalData.setting.appName;
... ... @@ -3924,10 +4669,10 @@ Page({
3924 4669 },
3925 4670  
3926 4671 clickShare() {
3927   - if(!getApp().globalData.user_id){
3928   - getApp().goto("/packageE/pages/togoin/togoin");
3929   - return false;
3930   - }
  4672 + if (!getApp().globalData.user_id) {
  4673 + getApp().goto("/packageE/pages/togoin/togoin");
  4674 + return false;
  4675 + }
3931 4676 this.setData({ share_hidden: true, });
3932 4677 },
3933 4678  
... ... @@ -3958,206 +4703,206 @@ Page({
3958 4703 },
3959 4704  
3960 4705 //获取预售的信息
3961   - async get_pre_prom(func) {
3962   - var th = this;
3963   - var presell_id = null;
3964   - var pre_arr = null;
3965   -
3966   - if (!th.data.pre_id) {
3967   - var presell_id = th.data.presell_id;
3968   - var url = "/api/weshop/marketing/marketingPresellList/list"
3969   - var rd = {
3970   - store_id: os.stoid,
3971   - presell_id: presell_id,
3972   - goods_id: th.data.gid
3973   - }
3974   - //------获取预售从表----------
3975   - await getApp().request.promiseGet(url, {
3976   - data: rd
3977   - }).then(res => {
3978   - if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
3979   - var arr = res.data.data[0];
3980   - presell_id = arr.presell_id;
3981   - th.setData({
3982   - presellList: arr,
3983   - })
3984   - }
3985   - })
  4706 + async get_pre_prom(func) {
  4707 + var th = this;
  4708 + var presell_id = null;
  4709 + var pre_arr = null;
3986 4710  
3987   - } else {
3988   - //------获取预售从表----------
3989   - await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/get/" + os.stoid + "/" + th.data.pre_id, {}).then(res => {
3990   - if (res.data.code == 0 && res.data.data) {
3991   - var arr = res.data.data;
3992   - presell_id = arr.presell_id;
3993   - th.setData({
3994   - presellList: arr,
3995   - })
3996   - }
3997   - })
  4711 + if (!th.data.pre_id) {
  4712 + var presell_id = th.data.presell_id;
  4713 + var url = "/api/weshop/marketing/marketingPresellList/list"
  4714 + var rd = {
  4715 + store_id: os.stoid,
  4716 + presell_id: presell_id,
  4717 + goods_id: th.data.gid
  4718 + }
  4719 + //------获取预售从表----------
  4720 + await getApp().request.promiseGet(url, {
  4721 + data: rd
  4722 + }).then(res => {
  4723 + if (res.data.code == 0 && res.data.data && res.data.data.length > 0) {
  4724 + var arr = res.data.data[0];
  4725 + presell_id = arr.presell_id;
  4726 + th.setData({
  4727 + presellList: arr,
  4728 + })
3998 4729 }
  4730 + })
3999 4731  
4000   - if (!presell_id) {
4001   - wx.showToast({title: "未找到活动商品", icon: 'none', duration: 3000});
4002   - ut.wx_back();
4003   - return false;
  4732 + } else {
  4733 + //------获取预售从表----------
  4734 + await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/get/" + os.stoid + "/" + th.data.pre_id, {}).then(res => {
  4735 + if (res.data.code == 0 && res.data.data) {
  4736 + var arr = res.data.data;
  4737 + presell_id = arr.presell_id;
  4738 + th.setData({
  4739 + presellList: arr,
  4740 + })
4004 4741 }
  4742 + })
  4743 + }
4005 4744  
4006   - var gnext=1;
4007   - //------获取预售主表----------
4008   - await getApp().request.promiseGet(`/api/weshop/marketing/marketingPresellForm/get/${os.stoid}/${presell_id}`, {}).then(res => {
4009   - if (res.data.code == 0 && res.data.data) {
4010   - var act_data = res.data.data;
4011   - if (act_data.is_end) {
4012   - wx.showToast({title: "活动已经结束", icon: 'none', duration: 3000});
4013   - setTimeout(function () {
4014   - ut.wx_back();
4015   - }, 2000)
4016   - gnext=0;
4017   - return false;
4018   - }
4019   - if (act_data.isuse == 0) {
4020   - wx.showToast({title: "活动未启用", icon: 'none', duration: 3000});
4021   - setTimeout(function () {
4022   - ut.wx_back();
4023   - }, 2000)
4024   - gnext=0;
4025   - return false;
4026   - }
4027   -
4028   - var err_txt="活动定金时间已经结束";
4029   - var end_time = act_data.end_time;
4030   - if (act_data.presell_type == 1) {
4031   - err_txt="活动时间已经结束";
4032   - }
4033   - if (end_time < ut.gettimestamp()) {
4034   - wx.showToast({title:err_txt, icon: 'none', duration: 3000});
4035   - setTimeout(function () {
4036   - getApp().goto("/pages/index/index/index");
4037   - }, 2000)
4038   - gnext=0;
4039   - return false;
4040   - }
4041   -
4042   - if (act_data.presell_type == 0) {
4043   - end_time = act_data.pay_enddate;
4044   - err_txt="活动尾款时间已经结束";
4045   - }
4046   - if (end_time < ut.gettimestamp()) {
4047   - wx.showToast({title:err_txt, icon: 'none', duration: 3000});
4048   - setTimeout(function () {
4049   - ut.wx_back();
4050   - }, 2000)
4051   - gnext=0;
4052   - return false;
4053   - }
4054   -
4055   - if (act_data.start_time > ut.gettimestamp()) {
4056   - wx.showToast({title:"活动还未开始", icon: 'none', duration: 3000});
4057   - setTimeout(function () {
4058   - ut.wx_back();
4059   - }, 2000)
4060   - gnext=0;
4061   - return false;
4062   - }
  4745 + if (!presell_id) {
  4746 + wx.showToast({ title: "未找到活动商品", icon: 'none', duration: 3000 });
  4747 + ut.wx_back();
  4748 + return false;
  4749 + }
4063 4750  
4064   - th.setData({
4065   - presellForm: res.data.data,
4066   - });
4067   - th.countDown(res.data.data.end_time)
4068   - }
4069   - })
  4751 + var gnext = 1;
  4752 + //------获取预售主表----------
  4753 + await getApp().request.promiseGet(`/api/weshop/marketing/marketingPresellForm/get/${os.stoid}/${presell_id}`, {}).then(res => {
  4754 + if (res.data.code == 0 && res.data.data) {
  4755 + var act_data = res.data.data;
  4756 + if (act_data.is_end) {
  4757 + wx.showToast({ title: "活动已经结束", icon: 'none', duration: 3000 });
  4758 + setTimeout(function () {
  4759 + ut.wx_back();
  4760 + }, 2000)
  4761 + gnext = 0;
  4762 + return false;
  4763 + }
  4764 + if (act_data.isuse == 0) {
  4765 + wx.showToast({ title: "活动未启用", icon: 'none', duration: 3000 });
  4766 + setTimeout(function () {
  4767 + ut.wx_back();
  4768 + }, 2000)
  4769 + gnext = 0;
  4770 + return false;
  4771 + }
4070 4772  
4071   - if(!gnext){
4072   - return false;
  4773 + var err_txt = "活动定金时间已经结束";
  4774 + var end_time = act_data.end_time;
  4775 + if (act_data.presell_type == 1) {
  4776 + err_txt = "活动时间已经结束";
  4777 + }
  4778 + if (end_time < ut.gettimestamp()) {
  4779 + wx.showToast({ title: err_txt, icon: 'none', duration: 3000 });
  4780 + setTimeout(function () {
  4781 + getApp().goto("/pages/index/index/index");
  4782 + }, 2000)
  4783 + gnext = 0;
  4784 + return false;
4073 4785 }
4074 4786  
4075   - var userInfo = getApp().globalData.userInfo;
4076   - var pre_data = {store_id: os.stoid, is_end: 0, timetype: 1, isuse: 1, prom_type: 8, prom_id: presell_id,pageSize:1000};
4077   - if (userInfo) {
4078   - pre_data.user_id = userInfo.user_id;
  4787 + if (act_data.presell_type == 0) {
  4788 + end_time = act_data.pay_enddate;
  4789 + err_txt = "活动尾款时间已经结束";
4079 4790 }
4080   - await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/page", {
4081   - data: pre_data,
4082   - }).then(e => {
4083   - if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) {
4084   -
4085   - th.data.all_pre_goods = e.data.data.pageData;
4086   - var idx = e.data.data.pageData.findIndex(function (ele) {
4087   - return ele.id == th.data.presellList.id;
4088   - })
4089   -
4090   - pre_arr = e.data.data.pageData[idx];
4091   - th.setData({pre_arr: pre_arr,show:1})
4092   - th.data.prom_buy_limit = pre_arr.vip_butyqty;
4093   - }
4094   - })
4095   - if (!pre_arr) {
4096   - wx.showToast({title: "当前会员身份不符或者时间已过期,无法参与", icon: 'none', duration: 3000});
4097   - setTimeout(function () {
4098   - ut.wx_back();
4099   - }, 2000)
4100   - return false;
  4791 + if (end_time < ut.gettimestamp()) {
  4792 + wx.showToast({ title: err_txt, icon: 'none', duration: 3000 });
  4793 + setTimeout(function () {
  4794 + ut.wx_back();
  4795 + }, 2000)
  4796 + gnext = 0;
  4797 + return false;
4101 4798 }
4102   - if (func) {
4103   - func();
  4799 +
  4800 + if (act_data.start_time > ut.gettimestamp()) {
  4801 + wx.showToast({ title: "活动还未开始", icon: 'none', duration: 3000 });
  4802 + setTimeout(function () {
  4803 + ut.wx_back();
  4804 + }, 2000)
  4805 + gnext = 0;
  4806 + return false;
4104 4807 }
4105   - },
4106 4808  
4107   - con_weixin:function () {
4108   - getApp().con_wx(this);
4109   - },
4110   -
4111   - // 预览海报
4112   - previewPoster() {
4113   - getApp().globalData.no_clear=1;
4114   - wx.previewImage({
4115   - current: this.data.shareImgPath, // 当前显示图片的http链接
4116   - urls: [this.data.shareImgPath] ,// 需要预览的图片http链接列表
4117   - });
4118   - },
4119   -
4120   -
4121   - click_contact:function () {
4122   - getApp().globalData.no_clear=1;
4123   - },
4124   -
4125   - //打开客服操作菜单
4126   - openCS() {
4127   - // 判断会员状态
4128   - let user_info = getApp().globalData.userInfo;
4129   - if (user_info == null || user_info.mobile == undefined || user_info.mobile == '' || user_info.mobile == null) {
4130   - wx.navigateTo({
4131   - url: '/packageE/pages/togoin/togoin',
4132   - })
4133   - return false;
4134   - };
4135   - // csType/在线客服设置:
4136   - // 0关闭(如果有设置热线电话,则显示拨打热线电话)、
4137   - // 1小程序客服、
4138   - // 2企业微信客服
4139   - if(this.data.sys_switch) {
4140   - let csType = this.data.sys_switch.weapp_customertype;
4141   - if(csType == 0) {
4142   - // 拨打电话号码
4143   - this.contactService();
4144   - } else {
4145   - this.getTel()
4146   - .then(() => {
4147   - self.setData({
4148   - hiddenCS: false,
4149   - });
4150   - });
4151   - };
4152   - };
4153   -
4154   - },
4155   -
4156   - //关闭客服操作菜单
4157   - closeCS() {
4158   - this.setData({
4159   - hiddenCS: true,
4160   - });
4161   - },
  4809 + th.setData({
  4810 + presellForm: res.data.data,
  4811 + });
  4812 + th.countDown(res.data.data.end_time)
  4813 + }
  4814 + })
  4815 +
  4816 + if (!gnext) {
  4817 + return false;
  4818 + }
  4819 +
  4820 + var userInfo = getApp().globalData.userInfo;
  4821 + var pre_data = { store_id: os.stoid, is_end: 0, timetype: 1, isuse: 1, prom_type: 8, prom_id: presell_id, pageSize: 1000 };
  4822 + if (userInfo) {
  4823 + pre_data.user_id = userInfo.user_id;
  4824 + }
  4825 + await getApp().request.promiseGet("/api/weshop/marketing/marketingPresellList/page", {
  4826 + data: pre_data,
  4827 + }).then(e => {
  4828 + if (e.data.code == 0 && e.data.data.pageData && e.data.data.pageData.length > 0) {
  4829 +
  4830 + th.data.all_pre_goods = e.data.data.pageData;
  4831 + var idx = e.data.data.pageData.findIndex(function (ele) {
  4832 + return ele.id == th.data.presellList.id;
  4833 + })
  4834 +
  4835 + pre_arr = e.data.data.pageData[idx];
  4836 + th.setData({ pre_arr: pre_arr, show: 1 })
  4837 + th.data.prom_buy_limit = pre_arr.vip_butyqty;
  4838 + }
  4839 + })
  4840 + if (!pre_arr) {
  4841 + wx.showToast({ title: "当前会员身份不符或者时间已过期,无法参与", icon: 'none', duration: 3000 });
  4842 + setTimeout(function () {
  4843 + ut.wx_back();
  4844 + }, 2000)
  4845 + return false;
  4846 + }
  4847 + if (func) {
  4848 + func();
  4849 + }
  4850 + },
  4851 +
  4852 + con_weixin: function () {
  4853 + getApp().con_wx(this);
  4854 + },
  4855 +
  4856 + // 预览海报
  4857 + previewPoster() {
  4858 + getApp().globalData.no_clear = 1;
  4859 + wx.previewImage({
  4860 + current: this.data.shareImgPath, // 当前显示图片的http链接
  4861 + urls: [this.data.shareImgPath],// 需要预览的图片http链接列表
  4862 + });
  4863 + },
  4864 +
  4865 +
  4866 + click_contact: function () {
  4867 + getApp().globalData.no_clear = 1;
  4868 + },
  4869 +
  4870 + //打开客服操作菜单
  4871 + openCS() {
  4872 + // 判断会员状态
  4873 + let user_info = getApp().globalData.userInfo;
  4874 + if (user_info == null || user_info.mobile == undefined || user_info.mobile == '' || user_info.mobile == null) {
  4875 + wx.navigateTo({
  4876 + url: '/packageE/pages/togoin/togoin',
  4877 + })
  4878 + return false;
  4879 + };
  4880 + // csType/在线客服设置:
  4881 + // 0关闭(如果有设置热线电话,则显示拨打热线电话)、
  4882 + // 1小程序客服、
  4883 + // 2企业微信客服
  4884 + if (this.data.sys_switch) {
  4885 + let csType = this.data.sys_switch.weapp_customertype;
  4886 + if (csType == 0) {
  4887 + // 拨打电话号码
  4888 + this.contactService();
  4889 + } else {
  4890 + this.getTel()
  4891 + .then(() => {
  4892 + self.setData({
  4893 + hiddenCS: false,
  4894 + });
  4895 + });
  4896 + };
  4897 + };
  4898 +
  4899 + },
  4900 +
  4901 + //关闭客服操作菜单
  4902 + closeCS() {
  4903 + this.setData({
  4904 + hiddenCS: true,
  4905 + });
  4906 + },
4162 4907  
4163 4908 });
... ...