123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257 |
- <template>
- <view class="pages-box">
- <view class="topup-listbtn-box">
-
- <view class="topup-listbtn-items" v-for="(item,index) in resultList" :key="index">
- <view :class="selected == item.id ? 'select_class' :'' " @click="select_items(item.id,item.price)">
- <view class="">{{item.title}}</view>
- <view class="" style="margin-top: 10rpx;">({{item.desc}})</view>
- <view class="" style="margin-top: 10rpx;">
- ¥<span style="font-size: 36rpx;font-weight: bold;">{{item.price}}</span>
- </view>
- <view class="" style="margin-top: 10rpx;"><span style="text-decoration:line-through;">¥{{item.original_price}}</span></view>
- </view>
- </view>
- </view>
-
- <view class="zf-fs-box">
- <text>支付方式:</text>
- <text>微信</text>
- </view>
- <view class="pages-btn" hover-class="hover-btn" @click="submitReview">确认协议并支付¥{{pay_text}}</view>
- <view class="checkbox-view">
- <checkbox-group @change="bindChange">
- <label class="checkbox">
- <checkbox value="1" :checked="checked"/>
- <text>开通前请阅读</text>
- </label>
- </checkbox-group>
- <text class="lable-text" @click="openPrivacyContract">《服务协议》</text>
- </view>
- </view>
- </template>
- <script>
- export default {
- data() {
- return {
- selected: 1,
- pay_text: '',
- sel_info: null,
- checked: true,
- tempFilePaths: '',
- resultList: [],
- order_id: ''
- }
- },
- created() {
- },
- onLoad(option) {
- this.tempFilePaths = option.tempFilePaths;
- this.getPrice();
- },
- methods: {
- select_items(n,t){
- this.selected = n;
- this.pay_text = t;
- },
- getPrice(){
- let that = this;
- that.$request.getPrice({}).then( res =>{
- console.log(res)
- if(res.code == 0){
- let resultList = res.data.result;
- let selected = that.selected;
- resultList.forEach( ele =>{
- if(ele.id == selected){
- that.pay_text = ele.price;
- that.sel_info = ele;
- }
- })
- that.resultList = resultList;
- }else{
- uni.showToast({
- title: res.message,
- icon: "none",
- })
- }
- }).catch( e =>{
- console.log(e)
- })
- },
- submitReview(){
- let that = this;
- let tempFilePaths = JSON.parse(that.tempFilePaths).tempFilePath;
- console.log(tempFilePaths)
- wx.uploadFile({
- url: 'https://ocr.lfwhzb.com/api/review',
- filePath: tempFilePaths,
- name: 'file',
- header: {
- token: uni.getStorageSync('token')
- },
- formData: { pay_id: that.selected },
- success(res) {
- let data = JSON.parse(res.data);
- if(data.code == 0){
- that.order_id = data.data.order_id;
- that.reviewPay(data.data.order_id);
- }else{
- uni.showToast({
- title: data.message,
- icon:"none"
- })
- }
- },
- fail(err) {
- console.log('上传失败:', err);
- }
- });
-
- // that.$request.submitReview({
- // file: that.file,
- // pay_id: that.selected,
- // }).then( res =>{
- // console.log(res)
- // if(res.code == 0){
- // that.order_id = res.data.order_id;
- // that.reviewPay(res.data.order_id);
- // }else{
- // uni.showToast({
- // title: res.message,
- // icon: "none",
- // })
- // }
- // }).catch( e =>{
- // console.log(e)
- // })
- },
- // 支付
- reviewPay(o){
- let that = this;
- that.$request.reviewPay({
- order_id: o,
- }).then( res =>{
- console.log(res)
- if(res.code == 0){
- let data = res.data;
- uni.requestPayment({
- "appId": data.appId, // 微信开放平台 - 应用 - AppId,注意和微信小程序、公众号 AppId 可能不一致
- "nonceStr": data.nonceStr, // 随机字符串
- "package": data.package, // 固定值
- "timeStamp": data.timeStamp, // 时间戳(单位:秒)
- "signType": data.signType, //签名类型
- "paySign": data.paySign ,// 签名,这里用的 MD5/RSA 签名
- success(res) {
- uni.showToast({
- title: '支付成功',
- icon: 'success'
- })
- setTimeout(() =>{
- uni.navigateTo({
- url:'../user/cp-cg'
- })
- },1000)
- },
- fail(e) {
- console.log(e)
- uni.showToast({
- title: '支付报错',
- icon: 'none'
- })
- }
- })
-
- }else{
- uni.showToast({
- title: res.message,
- icon: "none",
- })
- }
- }).catch( e =>{
- console.log(e)
- uni.showToast({
- title: e,
- icon: 'none'
- })
- })
- }
- }
- }
- </script>
- <style scoped>
- .pages-box{
- padding: 40rpx;
- box-sizing: border-box;
- }
- .topup-listbtn-box{
- padding: 10rpx 20rpx;
- box-sizing: border-box;
- display: flex;
- flex-wrap: wrap;
- align-items: center;
- }
- .topup-listbtn-box>view.topup-listbtn-items{
- width: 50%;
- padding: 15rpx;
- font-size: 28rpx;
- box-sizing: border-box;
- }
- .topup-listbtn-items>view{
- text-align: center;
- height: auto;
- border-radius: 8px;
- font-size: 28rpx;
- padding: 20rpx 0;
- box-shadow: 0 0 20rpx 2rpx #00000020;
- }
- .topup-listbtn-items>.select_class{
- background: #95bf7f;
- color: #fff;
- }
- .zf-fs-box{
- width: 462rpx;
- margin: 0 auto;
- margin-top: 160rpx;
- padding: 20rpx 30rpx 10rpx 0;
- box-sizing: border-box;
- display: flex;
- align-items: center;
- justify-content: space-between;
- }
- .pages-btn{
- width: 480rpx;
- height: 74rpx;
- line-height: 74rpx;
- text-align: center;
- background: #95bf7f;
- color: #fff;
- border-radius: 20px;
- margin: 10rpx auto;
- box-shadow: 0 0 20rpx 2rpx #00000020;
- }
- .hover-btn{
- opacity: 0.8;
- }
- .checkbox-view{
- width: 480rpx;
- margin: 0 auto;
- margin-top: 20rpx;
- font-size: 30rpx;
- color: #333;
- display: flex;
- align-items: center;
- }
- .checkbox{
- display: flex;
- align-items: center;
- }
- .lable-text{
- color: blue;
- }
- .checkbox checkbox{
- transform: scale(0.7);
- }
- </style>
|