123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398 |
- <import name="x-page" src="../../components/page/page.ux"></import>
- <template>
- <div class="consume-record__wrap">
- <div class="stack" style="background-color: #ff8b63" if={{activity}}>
- <image src="https://cdn-novel.iycdm.com/h5/channelActivity/activity-2020-04-17/20200417173207-bg.jpeg"></image>
- <div class="contain">
- <text class="promotion-title" if="{{activity.isForever!=='1'}}">活动时间:{{activity.startTime.substring(0,10)}} 至 {{activity.endTime.substring(0,10)}}</text>
- <div class="charge-item {{currentIdx==$idx?'charge-on':''}}" for="{{activity.products}}" @click="chooseItem($item,$idx)">
- <block if="{{$item.type=='YEAR_ORDER'}}">
- <text class="limit {{currentIdx==$idx?'checked':''}}">限充{{$item.limit}}次</text>
- <text class="title"><span>365包年</span></text>
- <text class="desc">全站小说免费阅读</text>
- </block>
- <block elif="{{$item.type=='QUARTER'}}">
- <text class="limit {{currentIdx==$idx?'checked':''}}">限充{{$item.limit}}次</text>
- <text class="title"><span>98元包季</span></text>
- <text class="desc">全站小说免费阅读</text>
- </block>
- <block else>
- <text class="limit {{currentIdx==$idx?'checked':''}}">限充{{$item.limit}}次</text>
- <text class="title">充<span>{{$item.price}}元</span>得<span>{{$item.total}}书币</span></text>
- <text class="desc">多得{{$item.given}}书币</text>
- </block>
- </div>
- <text class="charge-button" @click="wantCharge">
- 立即充值
- </text>
- </div>
- <div class="rule">
- <text class="rule-bd">活动说明</text>
- <text>1.此充值为书币充值,1元=100书币</text>
- <text>2.书币为虚拟物品,一经充值不得退款</text>
- <text>3.活动期间不限充值次数</text>
- </div>
- </div>
- <!-- <div class="loading-wrap" if="showLoading">
- <div class="loading-content">
- <progress type="circular"></progress>
- <text class="loading-text">{{loadingText}}</text>
- </div>
- </div> -->
- <div class="mask" if={{showPay}} @click="closeMask">
- <div class="pop-pay">
- <div class="title-pay"><text class="index"></text><text>支付方式</text>
- <image src="../../assets/imgs/close.png" @click="closeMask"></image>
- </div>
- <div class="pay-item" @click="changePayType(0)" if="{{activity.payChannels.wechat=='1'}}">
- <div class="item-left">
- <image src="../../assets/imgs/wechat.png"></image><text>微信支付</text>
- </div>
- <image src="../../assets/imgs/pay_checked.png" class="checked" if={{!payType}}></image>
- <image src="../../assets/imgs/rank_grey.png" class="checked" if={{payType}}></image>
- </div>
- <div class="pay-item" @click="changePayType(1)" if="{{activity.payChannels.ali=='1'}}">
- <div class="item-left">
- <image src="../../assets/imgs/zfb.png"></image><text>支付宝支付</text>
- </div>
- <image src="../../assets/imgs/rank_grey.png" class="checked" if={{!payType}}></image>
- <image src="../../assets/imgs/pay_checked.png" class="checked" if={{payType}}></image>
- </div>
- <text class="charge-now" @click="goPay">确认充值</text>
- </div>
- </div>
- </div>
- </template>
- <script>
- import { configWxPay, configAliPay } from "../../helper";
- import { getAcitivity, getUserInfo, checkWxOrder } from "../../api";
- import { getAppConfig, getToken } from '../../api/utils';
- import router from '@system.router';
- import prompt from '@system.prompt';
- export default {
- public: {
- token: '',
- send_order_id: '',
- },
- private: {
- showPay: false,
- activity: null,
- payType: 0,
- currentProduct: null,
- currentIdx:0,
- showLoading: false,
- },
- onInit() {
- console.log('sssss')
- //getAppConfig(this);
- this.getUserInfo();
- setTimeout(()=>{
- this.getAcitvy();
- },1000)
-
-
- },
- changePayType(type,evt) {
- evt.stopPropagation();
- this.payType = type;
- return false;
- },
- closeMask() {
- let a = 'this.token'
- this.showPay = false;
- },
- async getAcitvy() {
- let activity = await getAcitivity('8148bcb29074dafe1edd21dc06db9249');
- this.activity = activity;
- this.currentProduct = this.activity.products[0];
- },
- wantCharge() {
- this.showPay = true;
- },
- async getUserInfo() {
- let userinfo = await getUserInfo();
- this.send_order_id = userinfo.send_order_id || this.send_order_id;
- },
- chooseItem(product,idx) {
- this.currentProduct = product;
- this.currentIdx = idx;
- },
- async goPay(evt) {
- evt.stopPropagation();
- let cur_pay_type = this.payType;
- let product_id = this.currentProduct.product_id;
- let ret = null;
- if (cur_pay_type == 1) {
- ret = await configAliPay({ product_id: product_id, send_order_id: this.send_order_id, activity_token:this.token });
- }
- else {
- ret = await configWxPay({ product_id: product_id, send_order_id: this.send_order_id, activity_token:this.token});
- }
- // 成功支付后的回调操作
- if (ret.code === "9000") this.showWaitingWrap(ret);
- else this.showToastByCode(ret.code);
- },
- checkOrder(order_info) {
- this.showLoading = true;
- let { data, order } = order_info;
- let times = 10;
- /* this.loadingText = `订单查询中...${times}s`;
- this.timer = setInterval(async () => {
- if (times === 0) clearInterval(this.timer), this.showToastByCode("6004");
- else {
- times--;
- this.loadingText = `订单查询中...${times}s`;
- let fb = await checkWxOrder(order);
- if (fb && typeof fb === "object") clearInterval(this.timer), this.showToastByCode("9000");
- }
- }, 1000); */
- setTimeout(()=>{
- if (router.getLength() === 1) {
- router.replace({ uri: "/views/Index" });
- return true;
- } else {
- router.back()
- }
- },2000)
- },
- showToastByCode(code) {
- this.showLoading = false;
- let msg = "支付成功!";
- switch (code) {
- case "9000": (msg = "支付成功!", router.back()); break;
- case "8000": msg = "订单已提交,请等待结果"; break;
- case "4000": msg = "订单支付失败!"; break;
- case "5000": msg = "订单重复!"; break;
- case "6001": msg = "您已取消支付"; break;
- case "6002": msg = "网络错误!"; break;
- case "6004": msg = "请联系客服查询订单"; break;
- default: msg = "请联系客服" + code;
- }
-
- prompt.showToast({ message: msg });
-
- },
- showWaitingWrap(order) {
- prompt.showDialog({
- title: "支付结果",
- message: "请确认支付结果",
- buttons: [
- {
- text: "已支付",
- color: "#EF5952"
- },
- {
- text: "重新选择金额",
- color: "#999"
- }
- ],
- success: (data) => {
- if (data.index === 0) this.checkOrder(order);
- },
- cancel: () => {
- console.log("cancel");
- }
- });
- },
- }
- </script>
- <style lang="less">
- .mask {
- position: fixed;
- top: 0;
- bottom: 0;
- left: 0;
- right: 0;
- background-color: rgba(0, 0, 0, 0.56);
- flex-direction: column;
- align-items: center;
- justify-content: flex-end;
- z-index: 2;
- .charge-now {
- width: 450px;
- height: 80px;
- margin: 20px auto 0;
- border-radius: 40px;
- background-color: #ff6200;
- font-size: 28px;
- color: #fff;
- text-align: center;
- }
- .pay-item {
- justify-content: space-between;
- padding: 10px 30px;
- .checked {
- width: 40px;
- }
- .item-left {
- image {
- width: 60px;
- }
- text {
- font-size: 28px;
- font-weight: bolder;
- margin-left: 26px;
- }
- }
- }
- .pop-pay {
- height: 420px;
- padding: 30px 0;
- background-color: #fff;
- border-top-left-radius: 18px;
- width: 100%;
- flex-direction: column;
- border-top-right-radius: 18px;
- .title-pay {
- justify-content: space-between;
- margin-bottom: 30px;
- border-bottom: 2px solid #ccc;
- padding-bottom: 30px;
- padding-left: 30px;
- padding-right: 30px;
- text {
- color: #333;
- font-weight: bold;
- font-size: 32x;
- }
- image {
- width: 30px;
- }
- }
- }
- }
- .stack {
- width: 100%;
- flex-direction: column;
- align-items: center;
- image {
- width: 100%;
- }
- .charge-item{
- position: relative;
- .limit{
- width: 100px;
- height: 38px;
- font-size: 20px;
- line-height: 38px;
- text-align: center;
- background-color: #E6E6E6;
- color: #B3B3B3;
- border-bottom-left-radius: 10px;
- border-top-right-radius: 10px;
- position: absolute;
- right:0;
- top:0;
- }
- .checked{
- color:#fff;
- background-color: #E82B2F;
- }
- }
- .rule {
- flex-direction: column;
- margin-top: 30px;
- padding: 0 0 100px 0;
- width: 600px;
- margin-left: auto;
- margin-right: auto;
- text {
- text-align: left;
- font-size: 26px;
- color: #fff;
- padding: 10px 0;
- }
- .rule-bd {
- text-align: center;
- }
- }
- .contain {
- background-color: #fff;
- width: 700px;
- padding: 28px;
- border-radius: 14px;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- .promotion-title {
- font-weight: bold;
- font-size: 28px;
- text-align: center;
- margin: 10px 0 20px 0;
- }
- .charge-button {
- background-color: #e82b2f;
- width: 600px;
- height: 100px;
- line-height: 100px;
- color: #fff;
- font-weight: bold;
- text-align: center;
- margin-top: 20px;
- border-radius: 60px;
- }
-
- .charge-item {
- width: 600px;
- background-color:#fff;
- border:1px solid #e6e6e6;
- color: #333;
- flex-direction: column;
- text-align: center;
- height: 110px;
- justify-content: center;
- align-items: center;
- border-radius: 10px;
- margin: 15px 0;
- .title {
- text-align: center;
- font-size: 36px;
- font-weight: bold;
- span {
- color: #fd555d;
- }
- }
- .desc {
- text-align: center;
- font-size: 28px;
- margin-top: 5px;
- }
- }
- .charge-on{
- background-color: #ffe4c4;
- border: 1px solid #e82b2f;
- }
- }
- .loading-wrap {
- position: fixed;
- top: 0;
- bottom: 0;
- left: 0;
- right: 0;
- background-color: rgba(0, 0, 0, .6);
- justify-content: center;
- align-items: center;
- .loading-content {
- width: 300px;
- height: 100px;
- border-radius: 6px;
- background-color: #fff;
- flex-direction: column;
- justify-content: center;
- align-items: center;
- .loading-text {
- font-size: 26px;
- }
- }
- }
- }
- </style>
|