Selaa lähdekoodia

feat: 新增附件下载包移动端购买页

zhangyuhan 3 vuotta sitten
vanhempi
commit
60666569eb

+ 1 - 1
src/jfw/front/wxMyOrder.go

@@ -328,7 +328,7 @@ func (t *WxMyOrder) IntegralDetail(order_code string) {
 
 
 //
 //
 func (t *WxMyOrder) WxFilePackCreateOrder() {
 func (t *WxMyOrder) WxFilePackCreateOrder() {
-	t.Render("/weixin/filePack/createorder.html")
+	t.Render("/weixin/commonPay/filePack/createorder.html")
 }
 }
 
 
 //
 //

+ 11 - 0
src/jfw/modules/app/src/web/templates/commonPay/filePack/createorder.html

@@ -28,6 +28,16 @@
         border-radius: 0;
         border-radius: 0;
         margin: 0;
         margin: 0;
       }
       }
+      .top-tip-banner {
+        width: 7.5rem;
+        height: 0.88rem;
+        line-height: 0.88rem;
+        text-align: center;
+        background: #FEE9E8;
+        font-size: 0.26rem;
+        font-weight: 500;
+        color: #FB483D;
+      }
     </style>
     </style>
 </head>
 </head>
 <body>
 <body>
@@ -36,6 +46,7 @@
     <div class="j-main" id="app" v-cloak>
     <div class="j-main" id="app" v-cloak>
       <div class="j-container">
       <div class="j-container">
         <div class="j-main">
         <div class="j-main">
+          <div class="top-tip-banner">使用有效期至${endTime}<span v-if="endDay > 0">(剩 ${endDay} 天)</span></div>
           <div class="spec-list-container border-line-t" v-if="buyType !== 'upgrade'">
           <div class="spec-list-container border-line-t" v-if="buyType !== 'upgrade'">
             <div class="spec-title" v-show="specTitleShow">请选择规格</div>
             <div class="spec-title" v-show="specTitleShow">请选择规格</div>
             <div class="spec-list">
             <div class="spec-list">

+ 9 - 0
src/web/staticres/common-module/coupon/js/pay-order-template.js

@@ -352,6 +352,15 @@ var couponTem = {
         case 'areaPack-1year':
         case 'areaPack-1year':
           id = 1133
           id = 1133
           break;
           break;
+        case 'filePack-1':
+          id = 1141
+          break;
+        case 'filePack-2':
+          id = 1142
+          break;
+        case 'filePack-3':
+          id = 1143
+          break;
       }
       }
       return id;
       return id;
     },
     },

+ 97 - 76
src/web/staticres/common-module/file-pack/js/buy.js

@@ -3,6 +3,8 @@ var vm = new Vue({
   el: '#app',
   el: '#app',
   data: function () {
   data: function () {
     return {
     return {
+      endTime: '',
+      endDay: -1,
       sessKey: '$data-area-pack-buy',
       sessKey: '$data-area-pack-buy',
       preferentialShow: false,
       preferentialShow: false,
       specTitleShow: false,
       specTitleShow: false,
@@ -27,34 +29,38 @@ var vm = new Vue({
         provinceMaxCount: 15, // 选择的大于15表示全国
         provinceMaxCount: 15, // 选择的大于15表示全国
         month: {}
         month: {}
       },
       },
+      priceMap: {},
       specActive: 1,
       specActive: 1,
       specList: [
       specList: [
         {
         {
           cycleType: 1, // 月
           cycleType: 1, // 月
-          label: '1月',
-          value: '1month',
+          label: '5个附件',
+          value: '1',
           price: 0,
           price: 0,
           desc: '',
           desc: '',
           perDayPrice: 0,
           perDayPrice: 0,
-          productId: 1131,
+          productId: 1141,
+          id: 5
         },
         },
         {
         {
           cycleType: 2, // 季
           cycleType: 2, // 季
-          label: '1',
-          value: '3month',
+          label: '10个附件',
+          value: '2',
           price: 0,
           price: 0,
           desc: '',
           desc: '',
           perDayPrice: 0,
           perDayPrice: 0,
-          productId: 1132,
+          productId: 1142,
+          id: 10
         },
         },
         {
         {
           cycleType: 3, // 年
           cycleType: 3, // 年
-          label: '1年',
-          value: '1year',
+          label: '20个附件',
+          value: '3',
           price: 0,
           price: 0,
           desc: '',
           desc: '',
           perDayPrice: 0,
           perDayPrice: 0,
-          productId: 1133,
+          productId: 1143,
+          id: 20
         }
         }
       ],
       ],
       bottomConf: {
       bottomConf: {
@@ -190,7 +196,7 @@ var vm = new Vue({
     },
     },
   },
   },
   created: function () {
   created: function () {
-    this.getBuyType()
+    this.getVipEndTime()
   },
   },
   mounted: function () {
   mounted: function () {
     var restore = this.restoreState()
     var restore = this.restoreState()
@@ -209,6 +215,56 @@ var vm = new Vue({
     // }
     // }
   },
   },
   methods: {
   methods: {
+    getMonthEndTime: function (date) {
+      var tempDate = new Date(date)
+      let month = tempDate.getMonth()
+      var new_year = tempDate.getFullYear(); //取当前的年份
+      var new_month = ++month; //取下一个月的第一天,方便计算(最后一天不固定)
+      if (month > 12) {
+        new_month -= 12; //月份减
+        new_year++; //年份增
+      }
+      var new_date = new Date(new_year, new_month, 1); //取当年当月中的第一天
+      return (new Date(new_date.getTime() - 1000 * 60 * 60 * 24));
+    },
+    getDayDiff: function (date1, date2, unit) {
+      var myDate1 = typeof date1 === 'string' && date1.includes('-') ? date1.replace(/-/g, '/') : date1;
+      var myDate2 = typeof date2 === 'string' && date2.includes('-') ? date2.replace(/-/g, '/') : date2;
+      var map = {
+        day: 1000 * 60 * 60 * 24,
+        hour: 1000 * 60 * 60,
+        minute: 1000 * 60,
+        second: 1000,
+        ms: 1,
+      };
+      return ((new Date(myDate2) - new Date(myDate1)) / (map[unit]));
+    },
+    getEndTime: function (vipEndTime) {
+      var nowDate = new Date().getTime()
+      var monthEndDate = this.getMonthEndTime(nowDate)
+      if (vipEndTime) {
+        var vipEndDate = new Date(vipEndTime)
+        if (vipEndDate.getTime() < monthEndDate.getTime()) {
+          monthEndDate = vipEndDate
+        }
+      }
+      var diffDay = this.getDayDiff(nowDate, monthEndDate.getTime(), 'day')
+      const result = Math.ceil(diffDay)
+      this.endTime = monthEndDate.pattern('yyyy.MM.dd')
+      this.endDay = result
+    },
+    getVipEndTime: function () {
+      $.ajax({
+        url: '/subscribepay/vipsubscribe/getSubBuyMsg',
+        type: 'GET',
+        success: function (res) {
+          console.log(res)
+          if (res && res.data && res.data.endTime) {
+            this.getEndTime(res.data.endTime * 1000)
+          }
+        }.bind(this)
+      })
+    },
     showLoading: function () {
     showLoading: function () {
       return this.$toast.loading({
       return this.$toast.loading({
         duration: 0,
         duration: 0,
@@ -258,22 +314,6 @@ var vm = new Vue({
         }
         }
       }
       }
     },
     },
-    getBuyType: function () {
-      var buyTypeList = ['buy', 'renew', 'upgrade']
-      var buyType = utils.getParam('type')
-      if (buyTypeList.indexOf(buyType) !== -1) {
-        this.buyType = buyType
-      }
-      this.setBuyTypeInfo()
-    },
-    setBuyTypeInfo: function () {
-      // buy购买, renew续费, upgrade升级
-      if (this.buyType === 'renew') {
-        $('.jy-app-header .header-title').text('续费省份订阅包')
-      } else if (this.buyType === 'upgrade') {
-        $('.jy-app-header .header-title').text('升级省份订阅包')
-      } else {}
-    },
     getAlreadyBuyCount: function () {
     getAlreadyBuyCount: function () {
       var buyInfo = this.alreadyBuyInfo
       var buyInfo = this.alreadyBuyInfo
       if (!buyInfo) return 0
       if (!buyInfo) return 0
@@ -297,13 +337,18 @@ var vm = new Vue({
       var _this = this
       var _this = this
       var loading = this.showLoading()
       var loading = this.showLoading()
       $.ajax({
       $.ajax({
-        url: '/jypay/areaPack/price',
+        url: '/jypay/resourcePack/price',
         type: 'POST',
         type: 'POST',
+        data: {
+          'product': 'attachmentDownPack'
+        },
         success: function (res) {
         success: function (res) {
           loading && loading.clear()
           loading && loading.clear()
-          if (res) {
-            Object.assign(_this.priceInfo, res)
-            _this.getBuyInfo()
+          if (res && res.data) {
+
+            Object.assign(_this.priceMap, res.data)
+            // _this.getBuyInfo()
+            _this.getPrice()
           }
           }
         },
         },
         error: function () {
         error: function () {
@@ -470,23 +515,9 @@ var vm = new Vue({
     // 根据请求返回值,计算卡片展示金额
     // 根据请求返回值,计算卡片展示金额
     sortPrice: function () {
     sortPrice: function () {
       var priceInfoArr = []
       var priceInfoArr = []
-      var buyAreaCount = this.buyAreaCount
-
-      if (this.buyType === 'buy') {
-        if (buyAreaCount === 0) {
-          buyAreaCount = 1
-          this.alreadyBuyInfo.simulatedAmount = true
-        } else {
-          this.alreadyBuyInfo.simulatedAmount = false
-        }
-      }
 
 
       this.specList.forEach(function (spec) {
       this.specList.forEach(function (spec) {
-        var priceInfo = this.commonGetPrice(buyAreaCount, spec.cycleType)
-        spec.price = priceInfo.price
-        spec.perDayPrice = priceInfo.perDayPrice
-        spec.desc = '每天仅需' + priceInfo.perDayPrice + '元'
-        priceInfoArr.push(priceInfo)
+        spec.price = this.priceMap[spec.id] / 100
         this.renderGiftInfo(spec)
         this.renderGiftInfo(spec)
       }.bind(this))
       }.bind(this))
       return priceInfoArr
       return priceInfoArr
@@ -497,7 +528,7 @@ var vm = new Vue({
       if (this.buyType === 'buy' || this.buyType === 'renew') {
       if (this.buyType === 'buy' || this.buyType === 'renew') {
         // 获取被选中的规格卡片info
         // 获取被选中的规格卡片info
         var specItem = this.selectedSpecItem
         var specItem = this.selectedSpecItem
-        this.bottomConf.type = 'areaPack-' + specItem.value
+        this.bottomConf.type = 'filePack-' + specItem.value
         p = specItem.price
         p = specItem.price
       } else {
       } else {
         p = this.getUpgradePrice()
         p = this.getUpgradePrice()
@@ -557,19 +588,12 @@ var vm = new Vue({
     },
     },
     submitOrder: function () {
     submitOrder: function () {
       var _this = this
       var _this = this
-      if (!this.areaInfo) return
       var loading = this.showLoading()
       var loading = this.showLoading()
-      var orderTypeMap = {
-        'buy': 1,
-        'upgrade': 2,
-        'renew': 3
-      }
       var data = {
       var data = {
-        price: this.bottomConf.initPrice * 10000 / 100,
-        orderType: orderTypeMap[this.buyType],
-        area: JSON.stringify(this.areaInfo),
-        num: this.buyAreaCount, // 购买的数量
-        unit: this.selectedSpecItem.cycleType, // 单位:1月 2季 3年
+        "product":"attachmentDownPack",
+        "data":{
+          "num": this.selectedSpecItem.id
+        },
         order_phone: this.userInfo.phone,
         order_phone: this.userInfo.phone,
         lotteryId: this.$refs.couponRef.coupon.lotteryId,
         lotteryId: this.$refs.couponRef.coupon.lotteryId,
         useProduct: this.$refs.couponRef.getProductId(),
         useProduct: this.$refs.couponRef.getProductId(),
@@ -577,34 +601,31 @@ var vm = new Vue({
         discountId: this.selectedSpecItem.discountId
         discountId: this.selectedSpecItem.discountId
       }
       }
       $.ajax({
       $.ajax({
-        url: '/jypay/areaPack/createOrder',
-        type: 'POST',
-        data: data,
+        url: '/jypay/resourcePack/createOrder',
+        contentType: "application/json;charset=UTF-8",
+        dataType: "json",
+        type: "post",
+        processData: false,
+        data: JSON.stringify(data),
         success: function (res) {
         success: function (res) {
           loading && loading.clear()
           loading && loading.clear()
-          if (res.error_code === 0) {
-            if (res.data) {
+          if (res.status === 1) {
+            if (res.order_code) {
               if (utils.isWeiXinBrowser) {
               if (utils.isWeiXinBrowser) {
-                history.replaceState({}, '', '/weixin/common/areaPack/orderDetail?order_code=' + res.data.orderCode);
-                location.href = '/weixin/pay/checkout_areaPack?orderCode=' + res.data.orderCode
+                history.replaceState({}, '', '/weixin/common/filePack/orderDetail?order_code=' + res.order_code);
+                location.href = '/weixin/pay/checkout_filePack?orderCode=' + res.order_code
               } else {
               } else {
-                history.replaceState({}, '', '/jyapp/common/areaPack/orderDetail?order_code=' + res.data.orderCode);
-                location.href = "/jyapp/pay/checkout_areaPack?orderCode=" + res.data.orderCode + '&from=' + _this.buyType
+                history.replaceState({}, '', '/jyapp/common/filePack/orderDetail?order_code=' + res.order_code);
+                location.href = "/jyapp/pay/checkout_filePack?orderCode=" + res.order_code + '&from=' + _this.buyType
               }
               }
             } else {
             } else {
-              _this.showToast(res.error_msg)
+              _this.showToast(res.msg)
             }
             }
           } else {
           } else {
-            if (res.error_msg && res.error_msg.indexOf('超过') !== -1) {
-              var buyInfo = _this.alreadyBuyInfo
-              // 获取剩余周期
-              var lastCycle = getDateSub(buyInfo.ppstart, buyInfo.ppend)
-              var lastArr = []
-              if (lastCycle[0]) lastArr.push(lastCycle[0] + '年')
-              if (lastCycle[1]) lastArr.push(lastCycle[1] + '个月')
-              _this.showToast(`最长周期不可超过3年\n剩余周期:${lastArr.join('')}`)
+            if (res.msg) {
+              _this.showToast(res.msg)
             } else {
             } else {
-              _this.showToast(res.error_msg)
+              _this.showToast('请稍后重试')
             }
             }
           }
           }
         },
         },

+ 123 - 0
src/web/templates/weixin/commonPay/filePack/createorder.html

@@ -0,0 +1,123 @@
+<!DOCTYPE html>
+<html lang="zh-CN">
+<head>
+    <!--引入公共资源头部-->
+    {{include "/big-member/wx/meta.html"}}
+    <title>附件下载包充值</title>
+    <!--S-当前页面的css资源-->
+    <link rel="stylesheet" href=//cdn-common.jianyu360.com/cdn/lib/reset-css/5.0.1/reset.min.css />
+    <link rel="stylesheet" href=//cdn-common.jianyu360.com/cdn/lib/vant/2.12.24/lib/index.css />
+    <link rel="stylesheet" href=//cdn-common.jianyu360.com/cdn/lib/vant/2.12.24/lib/icon/local.css />
+    <link rel="stylesheet" href='{{Msg "seo" "cdn"}}/big-member/css/j-icons.css?v={{Msg "seo" "version"}}'>
+    <link rel="stylesheet" href='{{Msg "seo" "cdn"}}/common-module/coupon/css/pay-order-template.css?v={{Msg "seo" "version"}}' />
+    <link rel="stylesheet" href='{{Msg "seo" "cdn"}}/common-module/area-pack/css/buy.css?v={{Msg "seo" "version"}}' />
+    <style>
+      .notes-section .notes-section-content,
+      .notes-section .notes-section-title {
+        color: inherit;
+      }
+      .notes-section {
+        padding: 0;
+        border: 0;
+        font-size: 0.24rem;
+        font-weight: 500;
+        color: #9B9CA3;
+        line-height: 0.36rem;
+      }
+      .order-phone-group {
+        border-radius: 0;
+        margin: 0;
+      }
+      .top-tip-banner {
+        width: 7.5rem;
+        height: 0.88rem;
+        line-height: 0.88rem;
+        text-align: center;
+        background: #FEE9E8;
+        font-size: 0.26rem;
+        font-weight: 500;
+        color: #FB483D;
+      }
+    </style>
+</head>
+<body>
+<div class="j-container">
+    {{include "/big-member/header.html"}}
+    <div class="j-main" id="app" v-cloak>
+        <div class="j-container">
+            <div class="j-main">
+          <div class="top-tip-banner">使用有效期至${endTime}<span v-if="endDay > 0">(剩 ${endDay} 天)</span></div>
+                <div class="spec-list-container border-line-t" v-if="buyType !== 'upgrade'">
+                    <div class="spec-title" v-show="specTitleShow">请选择规格</div>
+                    <div class="spec-list">
+                        <div
+                                class="spec-item"
+                                :class="{ active: item.cycleType == specActive }"
+                                v-for="(item, index) in specList"
+                                @click="clickSpec(item)"
+                                :key="index">
+                            <span class="preferential-tag" v-if="preferentialShow">限时x折</span>
+                            <div class="spec-i-label">
+                                <span class="spec-i-l-text">${item.label}</span>
+                                <span class="spec-i-l-info" v-if="item.labelSubInfo" v-html="item.labelSubInfo"></span>
+                            </div>
+                            <div class="spec-i-sub">
+                                <div class="spec-i-text del" v-show="item.before">&yen; ${ item.before || 0 }</div>
+                                <div class="spec-i-text"><span>&yen;</span> <span class="price-count">${ item.price }</span></div>
+                            </div>
+<!--                <div class="spec-i-desc">${ item.desc }</div>-->
+                        </div>
+                    </div>
+                </div>
+                <div class="order-phone-group" :class="{ error: !validatorPhonePass }">
+                    <label for="order_phone">手机号码</label>
+                    <input id="order_phone" v-model="userInfo.phone" autocomplete='off' placeholder='请输入手机号码' maxlength='11' type='tel' />
+                    <p class="error-message">手机号码输入错误</p>
+                </div>
+                <div class="notes-to-buy">
+                    <section class="notes-section">
+                        <p class="notes-section-title">购买须知</p>
+                        <div class="notes-section-content" v-if="buyType === 'buy' || buyType === 'renew'">
+                1.仅限超级订阅用户充值附件下载个数时使用,可多次购买。<br />
+                2.使用有效期仅限超级订阅服务周期内的当月,次月清零,不可转赠。
+                        </div>
+                    </section>
+                </div>
+            </div>
+            <div class="j-footer">
+                <pay-order-template ref="couponRef" :config="bottomConf" @update="updateS" @save="savePageState" @update-coupon="afterUpdateCoupon"></pay-order-template>
+            </div>
+        </div>
+        <van-popup v-model="dialog.backTip" get-container="body" class="back-tip-wrapper" :close-on-click-overlay="false">
+            <div class="b-t-title">
+                <img src="/common-module/area-pack/images/messageTitle@3x.png" alt="">
+            </div>
+            <div class="b-t-content">
+                <div class="b-t-content-item">
+                    多订阅1个省份,获取商机概率<br />增加一倍,邀您体验!
+                </div>
+                <div class="b-t-content-item bg-f-orange">
+                    支持用户增加订阅区域时使用,每增购1个省可获取该省的招标采购信息
+                </div>
+                <div class="b-t-content-item bg-f-orange">
+                    按时间(月/季/年)、订阅省份个数计价,${perMonthArea}元省/月起。
+                </div>
+            </div>
+            <div class="b-t-footer">
+                <button class="button cancel" @click="dialog.backTip = false;history.back()">取消</button>
+                <button class="button confirm" @click="dialog.backTip = false">去购买</button>
+            </div>
+        </van-popup>
+    </div>
+</div>
+<!--S-当前页面的资源-->
+<script src=//cdn-common.jianyu360.com/cdn/lib/vue/2.6.11/vue.min.js></script>
+<script src=//cdn-common.jianyu360.com/cdn/lib/vant/2.12.24/lib/vant.min.js></script>
+<script src=//cdn-common.jianyu360.com/cdn/lib/zepto/1.2.0/zepto.min.js></script>
+{{include "/big-member/wx/commonjs.html"}}
+<script src='{{Msg "seo" "cdn"}}/common-module/coupon/js/pay-order-template.js?v={{Msg "seo" "version"}}'></script>
+<script src='{{Msg "seo" "cdn"}}/common-module/file-pack/js/buy.js?v={{Msg "seo" "version"}}'></script>
+<!--E-当前页面的资源-->
+</body>
+
+</html>