Commit 4912d9335305fa4241c2e81fe19c3ef6c0681502

Authored by yvan.ni
1 parent 8f2d8e0c

1. 在线客服浮动效果完成

2.  在兑换优惠券之前要有一个提示框
3.  平摊算法调用接口的优化
components/diy_service/diy_service.js 0 → 100644
  1 +Component({
  2 + properties: {
  3 + // 这里定义了innerText属性,属性值可以在组件使用时指定
  4 + object:{
  5 + type: Object,
  6 + value:null
  7 + },
  8 + },
  9 + data: {
  10 + iurl:getApp().globalData.setting.imghost
  11 + },
  12 +
  13 + lifetimes: {
  14 + attached: function() {
  15 + var th=this;
  16 + //----获取系统参数-----
  17 + getApp().getConfig2(function(e) {
  18 + var json_d = JSON.parse(e.switch_list);
  19 + th.setData({ sys_switch:json_d, })
  20 + })
  21 + }
  22 + },
  23 +
  24 + methods: {
  25 + berror:function(e){
  26 + var iurl=getApp().globalData.setting.imghost;
  27 + var ob={};
  28 + var txt="object.title_img";
  29 + ob[txt] = iurl +'/miniapp/images/logo.png';
  30 + this.setData(ob);
  31 + },
  32 +
  33 + //-- 跳到绑定注册会员 --
  34 + go_user:function(){
  35 + getApp().goto('/pages/getphone/getphone');
  36 + return false;
  37 + },
  38 +
  39 + //---------联系客服------------
  40 + contactService: function() {
  41 + getApp().getConfig(function(t) {
  42 + if (t.store_tel == undefined) {
  43 + getApp().request.get("/api/weshop/store/get/" + os.stoid, {
  44 + isShowLoading: 1,
  45 + data: {},
  46 + success: function(rs) {
  47 + getApp().globalData.config = rs.data.data;
  48 + if (rs.data.data.store_tel == null && rs.data.data.store_tel == undefined) {
  49 + getApp().my_warnning("商家未设置电话", 0, th);
  50 + return false;
  51 + }
  52 + wx.makePhoneCall({ phoneNumber: rs.data.data.store_tel, })
  53 + }
  54 + })
  55 + } else {
  56 + wx.makePhoneCall({ phoneNumber: t.store_tel, })
  57 + }
  58 + });
  59 + },
  60 + }
  61 +})
components/diy_service/diy_service.json 0 → 100644
  1 +{
  2 + "component": true,
  3 + "usingComponents": {}
  4 +}
0 \ No newline at end of file 5 \ No newline at end of file
components/diy_service/diy_service.wxml 0 → 100644
  1 +<!--有在线客户 和 打电话-->
  2 +<block wx:if="{{sys_switch.weapp_customertype}}">
  3 + <!-- 判断是不是有登陆 -->
  4 + <view wx:if="{{userInfo}}" class="custom-service" bindtap="go_user" >
  5 + <view style="text-align: center;">
  6 + <image class="cs-img" src="{{object.img}}"></image>
  7 + <view class="s_title" wx:if="{{object.title!=''}}">{{object.title}}</view>
  8 + </view>
  9 + </view>
  10 +
  11 + <button wx:else class="custom-service" open-type="contact" session-from="wechat|{{userInfo.user_id}}|{{userInfo.nickname}}|{{userInfo.head_pic}}">
  12 + <view style="text-align: center;">
  13 + <image class="cs-img" src="{{iurl}}/miniapp/images/custom-service.png"></image>
  14 + <view class="s_title" wx:if="{{object.title!=''}}">{{object.title}}</view>
  15 + </view>
  16 + </button>
  17 +</block>
  18 +
  19 +<block wx:else>
  20 + <view class="custom-service cart-ico new_split" bindtap="contactService">
  21 + <view style="text-align: center;">
  22 + <image class="cs-img" src="{{object.img}}"></image>
  23 + <view class="s_title" wx:if="{{object.title!=''}}">{{object.title}}</view>
  24 + </view>
  25 + </view>
  26 +</block>
0 \ No newline at end of file 27 \ No newline at end of file
components/diy_service/diy_service.wxss 0 → 100644
  1 +.custom-service{ width: 116rpx; height: 116rpx; border-radius: 50%; background-color: #fff;z-index: 100;
  2 + border: 1px solid #adadad; box-shadow: 0 0 10px 2px #adadad; line-height: 28rpx;
  3 + position: fixed; top: 40%; right: 2rpx; display: flex;align-items: center;justify-content: center;}
  4 +
  5 + .cs-img{ width: 36rpx; height: 36rpx;}
  6 +.s_title{ font-size: 20rpx;}
0 \ No newline at end of file 7 \ No newline at end of file
pages/cart/cart2/cart2.js
@@ -706,11 +706,33 @@ Page({ @@ -706,11 +706,33 @@ Page({
706 cart_item.prom_pt_json=[{"prom_id":item_map.prom_id,"dis":(item_map.price-item_map.prom_price).toFixed(2),"ispt":0}]; 706 cart_item.prom_pt_json=[{"prom_id":item_map.prom_id,"dis":(item_map.price-item_map.prom_price).toFixed(2),"ispt":0}];
707 } 707 }
708 708
  709 + //-- 如果系统要平摊到单品 --
  710 + if(!th.data.ispt_goods){
  711 +
  712 + var pt_data={
  713 + 'prom_id':item_map.prom_id,
  714 + 'dis': parseFloat((item_map.price-item_map.prom_price).toFixed(2)),
  715 + 'goods':item_map.goods
  716 + }
  717 +
  718 + var pt_res=null;
  719 + await getApp().request.promisePost("/api/weshop/order/getGoodsSplit",{is_json:1,data:pt_data}).then(res=>{
  720 + if(res.data.code==0){ pt_res=res.data.data; }
  721 + })
  722 + if(pt_res){
  723 + for (var io in item_map.goods){
  724 + //平摊赋值
  725 + item_map.goods[io].account=th.arr_get_goods(item_map.goods[io].goods_id,pt_res).fisrt_account;
  726 + item_map.goods[io].account_yu=th.arr_get_goods(item_map.goods[io].goods_id,pt_res).fisrt_account_yu;
  727 + }
  728 + }
  729 + }
  730 +
709 o_price-=(item_map.price-item_map.prom_price); 731 o_price-=(item_map.price-item_map.prom_price);
710 //如果有限制使用优惠券,就要减掉参与的活动商品的钱 732 //如果有限制使用优惠券,就要减掉参与的活动商品的钱
711 if(!item_map.is_xz_yh) q_conditin=o_price; 733 if(!item_map.is_xz_yh) q_conditin=o_price;
712 } 734 }
713 - 735 +
714 //--------循环计算商品是不是包邮,是不是使用优惠券,此时循环是商品从表----------- 736 //--------循环计算商品是不是包邮,是不是使用优惠券,此时循环是商品从表-----------
715 for(var j=0;j<item.length;j++){ 737 for(var j=0;j<item.length;j++){
716 if(item[j].prom_type==3 && item[j].prom_id==item_map.prom_id){ 738 if(item[j].prom_type==3 && item[j].prom_id==item_map.prom_id){
@@ -1473,6 +1495,29 @@ Page({ @@ -1473,6 +1495,29 @@ Page({
1473 return false; 1495 return false;
1474 } 1496 }
1475 } 1497 }
  1498 +
  1499 + //--- 如果有优惠促销的金额,要把金额先平摊下去 ---
  1500 + if(th.data.formData.cut_price>0 && !th.data.ispt_goods){
  1501 + var g_arr=new Array();
  1502 + g_arr.push(goods);
  1503 + var pt_data={
  1504 + 'prom_id':goods.prom_id,
  1505 + 'dis': parseFloat(th.data.formData.cut_price),
  1506 + 'goods':g_arr,
  1507 + }
  1508 +
  1509 + var pt_res=null;
  1510 + await getApp().request.promisePost("/api/weshop/order/getGoodsSplit",{is_json:1,data:pt_data}).then(res=>{
  1511 + if(res.data.code==0){ pt_res=res.data.data; }
  1512 + })
  1513 + if(pt_res){
  1514 + //平摊赋值
  1515 + goods.account=pt_res[0].fisrt_account;
  1516 + goods.account_yu=pt_res[0].fisrt_account_yu;
  1517 + }
  1518 + }
  1519 +
  1520 +
1476 //--组装优惠券的钱-- 1521 //--组装优惠券的钱--
1477 if(th.data.formData.coupon_price){ 1522 if(th.data.formData.coupon_price){
1478 item.coupon_price=th.data.formData.coupon_price; 1523 item.coupon_price=th.data.formData.coupon_price;
@@ -1653,6 +1698,13 @@ Page({ @@ -1653,6 +1698,13 @@ Page({
1653 } 1698 }
1654 } 1699 }
1655 1700
  1701 + //把优惠的平摊结果写进去
  1702 + if(g_item.account>=0 || g_item.account_yu!=0){
  1703 + if(g_item.account>=0) goods.account=g_item.account;
  1704 + if(g_item.account_yu!=0) goods.account_yu=g_item.account_yu;
  1705 + item.is_discount_amount=1;
  1706 + }
  1707 +
1656 //导购ID 1708 //导购ID
1657 if(g_item.guide_id){ 1709 if(g_item.guide_id){
1658 goods.guide_id=g_item.guide_id; 1710 goods.guide_id=g_item.guide_id;
@@ -2474,7 +2526,12 @@ Page({ @@ -2474,7 +2526,12 @@ Page({
2474 } 2526 }
2475 is_xz_yh=0; 2527 is_xz_yh=0;
2476 var item_price=gd.goods_price*gd.goods_num; 2528 var item_price=gd.goods_price*gd.goods_num;
  2529 + //-- 如果有平摊下去,有实收价格的时候,就要用account来计算价格 --
  2530 + if(gd.account!=null && gd.account!=undefined){
  2531 + item_price=gd.account*gd.goods_num;
  2532 + }
2477 ckeck_quan_price+=item_price; 2533 ckeck_quan_price+=item_price;
  2534 +
2478 //--组装价格list-- 2535 //--组装价格list--
2479 if (check_quan_price_list) { 2536 if (check_quan_price_list) {
2480 check_quan_price_list += "," +item_price; 2537 check_quan_price_list += "," +item_price;
@@ -2755,11 +2812,17 @@ Page({ @@ -2755,11 +2812,17 @@ Page({
2755 }, 2812 },
2756 2813
2757 //从优惠的映射中拿出商品从表的item 2814 //从优惠的映射中拿出商品从表的item
2758 - item_map_get_goods:function(goods_id,map){  
2759 - for(var i in map.goods){  
2760 - if(map.goods[i].goods_id==goods_id) return map.goods[i];  
2761 - }  
2762 - } 2815 + item_map_get_goods:function(goods_id,map){
  2816 + for(var i in map.goods){
  2817 + if(map.goods[i].goods_id==goods_id) return map.goods[i];
  2818 + }
  2819 + },
  2820 + //从优惠的映射中拿出商品从表的item
  2821 + arr_get_goods:function(goods_id,arr){
  2822 + for(var i in arr){
  2823 + if(arr[i].goods_id==goods_id) return arr[i];
  2824 + }
  2825 + }
2763 2826
2764 2827
2765 }); 2828 });
pages/index/index/index.json
@@ -16,6 +16,7 @@ @@ -16,6 +16,7 @@
16 "richtext": "/components/diy_richtext/diy_richtext", 16 "richtext": "/components/diy_richtext/diy_richtext",
17 "assist":"/components/diy_assist/diy_assist", 17 "assist":"/components/diy_assist/diy_assist",
18 "picMax": "/components/diy_picMax/diy_picMax", 18 "picMax": "/components/diy_picMax/diy_picMax",
19 - "mvideo": "/components/diy_video/diy_video" 19 + "mvideo": "/components/diy_video/diy_video",
  20 + "service": "/components/diy_service/diy_service"
20 } 21 }
21 } 22 }
22 \ No newline at end of file 23 \ No newline at end of file
pages/index/index/index.wxml
@@ -339,7 +339,12 @@ @@ -339,7 +339,12 @@
339 <!--图片组合--> 339 <!--图片组合-->
340 <block wx:if="{{item.ename=='picMix'}}"> 340 <block wx:if="{{item.ename=='picMix'}}">
341 <picMax object="{{item.content}}"></picMax> 341 <picMax object="{{item.content}}"></picMax>
342 - </block> 342 + </block>
  343 + <!--在线上客服-->
  344 + <block wx:if="{{item.ename=='onlineService'}}">
  345 + <service object="{{item.content}}"></service>
  346 + </block>
  347 +
343 </view> 348 </view>
344 </block> 349 </block>
345 </view> 350 </view>
pages/template/index.json
@@ -17,6 +17,7 @@ @@ -17,6 +17,7 @@
17 "richtext": "/components/diy_richtext/diy_richtext", 17 "richtext": "/components/diy_richtext/diy_richtext",
18 "assist":"/components/diy_assist/diy_assist", 18 "assist":"/components/diy_assist/diy_assist",
19 "picMax": "/components/diy_picMax/diy_picMax", 19 "picMax": "/components/diy_picMax/diy_picMax",
20 - "mvideo": "/components/diy_video/diy_video" 20 + "mvideo": "/components/diy_video/diy_video",
  21 + "service": "/components/diy_service/diy_service"
21 } 22 }
22 } 23 }
23 \ No newline at end of file 24 \ No newline at end of file
pages/template/index.wxml
@@ -53,6 +53,10 @@ @@ -53,6 +53,10 @@
53 <block wx:if="{{item.ename=='picMix'}}"> 53 <block wx:if="{{item.ename=='picMix'}}">
54 <picMax object="{{item.content}}"></picMax> 54 <picMax object="{{item.content}}"></picMax>
55 </block> 55 </block>
  56 + <!--在线上客服-->
  57 + <block wx:if="{{item.ename=='onlineService'}}">
  58 + <service object="{{item.content}}"></service>
  59 + </block>
56 </view> 60 </view>
57 </block> 61 </block>
58 </view> 62 </view>
pages/user/coupons/exchange/exchange.js
@@ -60,9 +60,17 @@ Page({ @@ -60,9 +60,17 @@ Page({
60 * 点击兑换 60 * 点击兑换
61 */ 61 */
62 async click(e) { 62 async click(e) {
63 - var monye=e.currentTarget.dataset.monye;  
64 - var integr=e.currentTarget.dataset.integr;  
65 - //var integr = "-" + integr; 63 + var th=this;
  64 + this.data.monye=e.currentTarget.dataset.monye;
  65 + this.data.integr=e.currentTarget.dataset.integr;
  66 + var my_con = this.selectComponent("#my_con"); //组件的id
  67 + var title="是否使用"+th.data.integr+"积分兑换代金券面值"+th.data.monye+"元";
  68 + my_con.open(title, "确定", "取消", th.sure_pay, null)
  69 + },
  70 +
  71 + sure_pay:function(){
  72 + var monye=this.data.monye;
  73 + var integr=this.data.integr;
66 74
67 var user_id = getApp().globalData.user_id; 75 var user_id = getApp().globalData.user_id;
68 console.log(integr,"是什么微卷",typeof integr,monye); 76 console.log(integr,"是什么微卷",typeof integr,monye);
@@ -81,10 +89,11 @@ Page({ @@ -81,10 +89,11 @@ Page({
81 getApp().showWarning("积分不足"); 89 getApp().showWarning("积分不足");
82 } 90 }
83 } 91 }
84 -  
85 - })  
86 92
  93 + })
87 }, 94 },
  95 +
  96 +
88 /** 97 /**
89 * 生命周期函数--监听页面显示 98 * 生命周期函数--监听页面显示
90 */ 99 */
pages/user/coupons/exchange/exchange.json
1 { 1 {
2 - "usingComponents": {} 2 + "usingComponents": {
  3 + "my_confirm": "/components/my_confirm/my_confirm"
  4 + }
3 } 5 }
4 \ No newline at end of file 6 \ No newline at end of file
pages/user/coupons/exchange/exchange.wxml
@@ -8,4 +8,5 @@ @@ -8,4 +8,5 @@
8 <view class='mb20'>{{result.Integral}}积分兑换{{filter.getNum(result.ToSum)}}元微券</view> 8 <view class='mb20'>{{result.Integral}}积分兑换{{filter.getNum(result.ToSum)}}元微券</view>
9 <view class='jf-btn' bindtap='click' data-monye='{{result.ToSum}}' data-integr="{{result.Integral}}">立即兑换</view> 9 <view class='jf-btn' bindtap='click' data-monye='{{result.ToSum}}' data-integr="{{result.Integral}}">立即兑换</view>
10 </view> 10 </view>
11 -</block>  
12 \ No newline at end of file 11 \ No newline at end of file
  12 +</block>
  13 +<my_confirm id="my_con"></my_confirm>
13 \ No newline at end of file 14 \ No newline at end of file
utils/request.js
@@ -191,13 +191,19 @@ module.exports = { @@ -191,13 +191,19 @@ module.exports = {
191 promisePost:function(url,data){ 191 promisePost:function(url,data){
192 var th=this; 192 var th=this;
193 if(url.indexOf("http")==-1) url=getApp().globalData.setting.url +url; 193 if(url.indexOf("http")==-1) url=getApp().globalData.setting.url +url;
  194 + var post_data=data.data;
  195 + var header={"content-type": "application/x-www-form-urlencoded" };
  196 + if(data.is_json){
  197 + header={ 'content-type': 'application/json'};
  198 + post_data=JSON.stringify(post_data);
  199 + }
194 return new Promise((resolve, reject) => { 200 return new Promise((resolve, reject) => {
195 data.isShowLoading && th.showLoading(); 201 data.isShowLoading && th.showLoading();
196 wx.request({ 202 wx.request({
197 url, 203 url,
198 method: 'POST', 204 method: 'POST',
199 - header: {"content-type": "application/x-www-form-urlencoded" },  
200 - data:data.data, 205 + header: header,
  206 + data:post_data,
201 success(res) { 207 success(res) {
202 data.isShowLoading && th.hideLoading(); 208 data.isShowLoading && th.hideLoading();
203 resolve(res); 209 resolve(res);