123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482 |
- <template>
- <view class="pd16_15">
- <view class="box pd16_15 flex">
- <image class="tuan-buy-l" :src="buydata.img" mode="aspectFill"></image>
- <view class="tuan-buy-r pl15">
- <view v-if="mid>0" class="ft14 ftw600 cl-main">{{buydata.name}}【单集购买】【ID:{{mid}} 】</view>
- <view v-else class="ft14 ftw600 cl-main">{{buydata.title}}</view>
- <view v-if="mid>0" class="mt12 alcenter">
- <view>
- <text class="ft14 cl-orange">单集会员价:</text>
- <text class="ft16 cl-orange ftw600">¥{{buydata.vippriced*1}}{{hbmc}}</text>
- </view>
- <view>
- <text class="ft14 cl-notice">单集普通价:</text>
- <text class="ft14 cl-notice">{{buydata.priced*1}}{{hbmc}}</text>
- </view>
- </view>
- <view v-else class="mt12 alcenter">
- <view>
- <text class="ft14 cl-orange">全集会员价:</text>
- <text class="ft16 cl-orange ftw600">¥{{buydata.vippriceq*1}}{{hbmc}}</text>
- </view>
- <view>
- <text class="ft14 cl-notice">全集普通价:</text>
- <text class="ft14 cl-notice">¥{{buydata.priceq*1}}{{hbmc}}</text>
- </view>
-
- </view>
- </view>
- </view>
- <view class="box mt16 pd16_15">
- <!-- <view class="flex alcenter center">
- <text class="iconfont iconbtn_plus ft32" @click="jianAct" style="color: #5C5E66;"></text>
- <view class="ft16 ftw600 cl-main" style="width: 100rpx; text-align: center;">{{num}}</view>
- <text class="iconfont iconbtn_add ft32" @click="jiaAct" :style="{color:tempColor}"></text>
- </view>
- <view class="bd-line mt16 mb16"></view>
- <view class="flex alcenter space">
- <text class="ft14 cl-info2">优惠券</text>
- <view>
- <select-coupon v-model="coupon_id" :coupons="coupons"></select-coupon>
- </view>
- </view>
- <view class="bd-line mt16 mb16"></view>
- <view class="flex alcenter space">
- <text class="ft14 cl-info2">会员优惠</text>
- <text class="ft16 cl-main ftw600">-¥20</text>
- </view>
- <view class="bd-line mt16 mb16"></view> -->
- <view class="flex alcenter space">
- <text class="ft14 cl-info2">需支付</text>
- <text class="ft16 cl-main ftw600 cl-orange">{{pricebuy*1}}</text>
- </view>
- </view>
-
- <view class="box mt16 pd16_15">
- <view class="ft16 pb16 ftw600 cl-main">支付方式</view>
- <view class="bd-line mt16"></view>
- <radio-group @change="changeType">
- <!-- #ifdef MP-TOUTIAO -->
- <view class="pt16 pb16 flex alcenter space" style="display: none;">
- <view class="flex alcenter">
- <text class="iconfont iconicon_pay_balance ft32 cl-green"></text>
- <text class="ml15 ft14 ftw500 cl-main">抖音支付</text>
- </view>
- <view>
- <radio value="TOUTIAO" :checked="payType == 'TOUTIAO'" :color="tempColor" />
- </view>
- </view>
- <view class="bd-line" style="display: none;"></view>
- <!-- #endif -->
- <!-- #ifdef MP-WEIXIN -->
- <view class="pt16 pb16 flex alcenter space" style="display: none;">
- <view class="flex alcenter">
- <text class="iconfont iconicon_pay_balance ft32 cl-green"></text>
- <text class="ml15 ft14 ftw500 cl-main">微信支付</text>
- </view>
- <view>
- <radio value="weixin" :checked="payType == 'weixin'" :color="tempColor" />
- </view>
- </view>
- <view class="bd-line" style="display: none;"></view>
- <!-- #endif -->
- <view class="pt16 flex alcenter space">
- <view class="flex alcenter">
- <text class="iconfont iconicon_pay_balance ft32" style="color: #FFBD1E;"></text>
- <text class="ml15 ft14 ftw500 cl-main">{{hbmc}}支付</text>
- <!-- <text class="ml10 ft12 cl-notice">余额为0,不可用</text> -->
- </view>
- <view>
- <radio value="money" :checked="payType == 'money'" :disabled="false" :color="tempColor" />
- </view>
- </view>
- </radio-group>
- </view>
- <view class="form-footer-h">
- <view class="form-footer form-footer-h">
- <view class="form-footer-main pd10_15">
- <button v-if="mid>0" class="btn-big" @click="okTap" :style="getBtnStyle">支付{{pricebuy*1}}</button>
- <button v-else class="btn-big" @click="okTap" :style="getBtnStyle">支付 {{pricebuy*1}}</button>
- </view>
- </view>
- </view>
- </view>
- </template>
- <script>
- export default{
- data(){
- return {
- payType:'weixin',
- num:1,
- coupon_id:0,
- buydata:[],
- buytype:'微信',
- dataList:[],
- money:0,
- mid:0,
- openid:'',
- pricebuy:0,
- wxlx:'wxh5',
- hbmc:'',
- coupons:[
- {coupon_id:1,num:20},
- {coupon_id:2,num:30},
- {coupon_id:3,num:40},
- ],
- }
- },
- onLoad(option){
- this.hbmc=uni.getStorageSync("config").site.hbmc
- if(option.mid){
- this.mid=option.mid
- }
- this.buydata=uni.getStorageSync("buydata")
- if(this.mid>0 && this.buydata.isvip==2){
- this.pricebuy=this.buydata.vippriced
- }else if(this.mid>0 && this.buydata.isvip==1){
- this.pricebuy=this.buydata.priced
- }else if(this.mid==0 && this.buydata.isvip==2){
- this.pricebuy=this.buydata.vippriceq
- }else if(this.mid==0 && this.buydata.isvip==1){
- this.pricebuy=this.buydata.priceq
- }
- // #ifdef MP-TOUTIAO
- this.buytype='TOUTIAO'
- this.payType='TOUTIAO'
- // #endif
- //#ifdef MP-WEIXIN
- this.wxlx='wxxcx'
- this.wxlogin()
- //#endif
- //#ifdef H5
- var ua = window.navigator.userAgent.toLowerCase();
- if(ua.match(/MicroMessenger/i) == 'micromessenger'){
- this.wxlx = 'wxgzh';
- }
- //#endif
- },
- onShow() {
- if(uni.getStorageSync("userinfo").token){
- this.ongrzlTap()
- this.money=uni.getStorageSync("userinfo").money
- }else{
- uni.showModal({
- title: '温馨提示',
- content: '请先登录',
- showCancel: true,
- confirmText: "登录",
- success: function (res) {
- if (res.confirm) {
- uni.navigateTo({
- url:'/pages/login/login'
- })
- } else if (res.cancel) {
- uni.navigateBack();
- }
- }
- });
- }
- },
- computed:{
- getCouponMoney(){
- if(this.coupons.length > 0){
- for(var a in this.coupons){
- if(this.coupons[a].coupon_id == this.coupon_id){
- return this.coupons[a].num;
- }
- }
- }
- return 0;
- }
- },
- methods:{
- okTap(){
- var thia=this
- this.dataList=this.buydata;
-
- this.dataList.sum=1;
- this.dataList.buytype=this.buytype;
- //https://rw.gzzsw.cn/api/pay/index?token=a69720a4-6c4c-4baf-b269-d5260b821c7a
- let data = this.dataList;
- data.pricebuy=thia.pricebuy
- data.token = uni.getStorageSync("userinfo").token;
- data.uid = uni.getStorageSync("userinfo").id;
- if(this.mid>0){
- data.lx=2;//1 全章购买 2单集购买
- data.smid=this.mid;
- data.namet=data.name+'【单集购买】【ID:'+this.mid+' 】';
- }else{
- data.lx=1;//1 全章购买 2单集购买
- data.smid=0;
- data.namet=data.name
- }
- data.wxlx=this.wxlx;
- data.openid=this.openid;
- data.info=[];
- console.log(data)
- uni.request({
- url: this.configs.webUrl+'/api/pay/videopay',
- data: data,
- success: resa =>{
- //console.log(resa.data);
- if(thia.dataList.buytype=='微信'){
- if(this.wxlx=='wxxcx' && resa.data.code==1){
- //console.log(resa.data.code);
- this.wxxcx(resa.data.data);
- }else{
- // #ifdef APP-PLUS
-
- uni.navigateTo({
- url:'/pages/client/webva?url='+resa.data.data
- })
- //plus.runtime.openURL(res.data.data);
- // #endif
- // #ifdef H5
- window.open(resa.data.data, "_self")
- // #endif
- }
- }else if(thia.dataList.buytype=='余额'){
- if(resa.data.code==1){
- //pages/user/task/task
- uni.showModal({
- title: '提示',
- content: resa.data.msg,
- showCancel: false,
- success: res => {
- uni.setStorage({
- key: 'isbuy',
- data: 2
- })
- uni.navigateBack();
- // uni.navigateBack({
- // delta: 2
- // });
- }
- });
- }else{
- if(resa.data.msg=='余额不足'){
- uni.showModal({
- title: '提示',
- content: thia.hbmc+'不足',
- showCancel: true,
- confirmText: "充值",
- success: function (res) {
- if (res.confirm) {
- var pricebuy=thia.pricebuy
- uni.navigateTo({
- url:"/pages/client/vipcard/recharge?price="+pricebuy*1
- })
- } else if (res.cancel) {
- //uni.navigateBack();
- }
- }
- });
- }else{
- uni.showModal({
- title: '提示',
- content: resa.data.msg,
- showCancel: false,
- success: res => {
- uni.navigateBack();
- }
- });
- }
- }
- }else if(thia.dataList.buytype=='TOUTIAO'){
- if(resa.data.code==1){
- this.ttxcx(resa.data.data);
- }else{
- uni.showModal({
- title: '支付失败',
- content: JSON.stringify(resa.data.msg),
- showCancel: false,
- confirmText: "确定",
- success: function (ress) {
- if (res.confirm) {
- //uni.navigateBack();
- } else if (res.cancel) {
-
- }
- }
- });
- }
- }
- },
- fail: (data, code) => {
- console.log('fail' + JSON.stringify(data));
- }
- });
- },
-
- wxxcx(data){
- uni.requestPayment({
- "provider": 'wxpay',
- "appId": data.appId,
- "timeStamp": data.timeStamp+'',
- "nonceStr": data.nonceStr,
- "package": data.package,
- "signType": 'MD5',
- "paySign": data.sign,
- success: function (res1) {
- uni.showModal({
- title: '温馨提示',
- content: '支付成功',
- showCancel: false,
- confirmText: "确定",
- success: function (res) {
- if (res.confirm) {
- uni.setStorage({
- key: 'isbuy',
- data: 2
- })
- uni.navigateBack();
- } else if (res.cancel) {
-
- }
- }
- });
- //uni.showToast({ title: '支付成功',icon:"none" });
- console.log('success:' + JSON.stringify(res1));
- },
- fail: function (err1) {
- uni.showModal({
- title: '温馨提示',
- content: JSON.stringify(err1),
- showCancel: false,
- confirmText: "确定",
- success: function (res) {
- if (res.confirm) {
- //uni.navigateBack();
- } else if (res.cancel) {
-
- }
- }
- });
- //uni.showToast({ title: JSON.stringify(err1),icon:"none" });
- console.log('fail:' + JSON.stringify(err1));
- }
- });
- },
- async ongrzlTap(){
- let data = {};
- data.token = uni.getStorageSync("userinfo").token;
- data.uid = uni.getStorageSync("userinfo").id;
- uni.request({
- url: this.configs.webUrl+'/api/user/index',
- data: data,
- success: res =>{
- if(res.data.code==1){
- let ionfo=res.data.data
- ionfo.isLogin=true
- this.userinfo=ionfo
- uni.setStorage({//缓存配置信息
- key: 'userinfo',
- data: res.data.data
- })
- if(res.data.data.avatar){
- var str = res.data.data.avatar;
- if(str.indexOf("data:image") != -1){
- this.avatar='';
- }else{
- if(str.indexOf("http") != -1){
- this.avatar=res.data.data.avatar;
- }else{
- this.avatar=this.configs.imgUrl+res.data.data.avatar;
- }
- }
- }else{
- this.avatar='';
- }
- }else{
- uni.showToast({ title: res.data.msg,icon:"none" });
- }
- },
- fail: (data, code) => {
- //console.log('fail' + JSON.stringify(data));
- }
- });
- },
- jianAct(){
- if(this.num == 1) return;
- this.num = this.num - 1;
- },
- jiaAct(){
- if(this.num > 99) return; //后面改为库存数量
- this.num = this.num + 1;
- },
- changeType(e){
- this.payType = e.detail.value;
- if(e.detail.value=='money'){
- this.buytype = '余额';
- }
- if(e.detail.value=='weixin'){
- this.buytype = '微信';
- }
- if(e.detail.value=='TOUTIAO'){
- this.payType = 'TOUTIAO';
- this.buytype = 'TOUTIAO';
- }
- },
- wxlogin(){
- var this_=this
- uni.login({
- timeout: 10000,
- provider: 'weixin', //如果是uniapp,在这里需要标明平台的类型,支持的参数请查阅uniapp官网的uni.login()文档
- success: (res) => {
- console.log(res);
- //登陆成功的回调
- uni.request({
- url: this.configs.webUrl+'/api/user/getOpenid',
- method:'GET',
- data: {
- token: uni.getStorageSync("userinfo").token, //你的小程序的secret,
- code: res.code //wx.login 登录成功后的code
- },
- success: (cts) => {
- console.log(cts.data.code);
- if(cts.data.code==1){
- this_.openid=cts.data.data.openid
- }else{
- uni.showModal({
- title: '温馨提示',
- content: JSON.stringify(cts.data),
- showCancel: true,
- confirmText: "确定",
- success: function (res) {
- if (res.confirm) {
- uni.navigateBack();
- } else if (res.cancel) {
-
- }
- }
- });
- }
- },
- fail: (err1) => {
- console.log(err1);
- //失败的回调
- }
- });
-
- },
- fail: (err) => {
- console.log(err);
- //登陆失败的回调
- }
- })
- }
- }
- }
- </script>
- <style>
- .tuan-buy-l{
- width: 200rpx;
- height: 150rpx;
- background: #F2F2F2;
- }
- .tuan-buy-r{
- width: calc(100% - 200rpx);
- }
- </style>
|