170 lines
3.9 KiB
JavaScript
170 lines
3.9 KiB
JavaScript
// packageD/article/articleList/articleList.js
|
|
var app = getApp();
|
|
var yz_pay = require("../../../mycomponent/yz_pay/yz_pay");
|
|
import utils from '../../../utils/util.js';
|
|
Page({
|
|
behaviors: [yz_pay],
|
|
/**
|
|
* 页面的初始数据
|
|
*/
|
|
data: {
|
|
language: '',
|
|
id: '',
|
|
showPopup: false,
|
|
ios_virtual_pay: false
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面加载
|
|
*/
|
|
onLoad: function(options) {
|
|
this.setData({
|
|
id: options.article_id
|
|
});
|
|
console.log(options.id);
|
|
this.getData();
|
|
try {
|
|
var value = wx.getStorageSync('ios_virtual_pay');
|
|
if (value) {
|
|
this.setData({
|
|
ios_virtual_pay: value
|
|
});
|
|
}
|
|
} catch (e) {
|
|
console.log(e);
|
|
}
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面初次渲染完成
|
|
*/
|
|
onReady: function () {
|
|
let language = wx.getStorageSync('langIndex');
|
|
this.setData({ 'language': language.en});
|
|
},
|
|
|
|
/**
|
|
* 生命周期函数--监听页面显示
|
|
*/
|
|
onShow: function() {
|
|
|
|
},
|
|
|
|
/**
|
|
* 用户点击右上角分享
|
|
*/
|
|
onShareAppMessage: function() {
|
|
var value = wx.getStorageSync("yz_uid");
|
|
var mid = "";
|
|
if (value) {
|
|
mid = value;
|
|
}
|
|
return {
|
|
path: "/packageA/member/article/articleContent/articleContent?article_id=" + this.data.id + "&mid=" + mid,
|
|
title: this.data.dataInfo&&this.data.dataInfo.title||'',
|
|
imageUrl: this.data.dataInfo&&this.data.dataInfo.thumb ? this.data.dataInfo.thumb : "",
|
|
};
|
|
},
|
|
showzhifu() {
|
|
if (this.data.ios_virtual_pay) {
|
|
wx.showModal({
|
|
title: '提示',
|
|
content: '十分抱歉,由于相关规定,你暂时无法在这里充值!',
|
|
confirmText: '知道了',
|
|
showCancel: false,
|
|
success(res) {
|
|
if (res.confirm) {
|
|
console.log(res.confirm);
|
|
}
|
|
}
|
|
});
|
|
return false;
|
|
}
|
|
this.getPayData();
|
|
this.setData({
|
|
showPopup: true
|
|
});
|
|
},
|
|
tapPay(e) {
|
|
let is_type = e.currentTarget.dataset.value;
|
|
let is_money = this.data.dataInfo.money;
|
|
let name = e.currentTarget.dataset.name;
|
|
console.log(is_type, is_money, name);
|
|
let json = {
|
|
pay_id: is_type,
|
|
money: is_money,
|
|
pay_name: name,
|
|
id: this.data.id,
|
|
art: 'pay'
|
|
};
|
|
let urlStr = app.getNetAddresss("plugin.article-pay.api.index.orderPay");
|
|
urlStr += '&client_type=2';
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
data: json,
|
|
success: (resdata)=> {
|
|
let res = resdata.data;
|
|
if (res.result == 1) {
|
|
this.rechargePay(is_type, res, res.data.ordersn);
|
|
}else{
|
|
wx.showToast({
|
|
title: res.msg,
|
|
icon:'none',
|
|
duration:1000
|
|
});
|
|
}
|
|
},
|
|
fail: (res)=> {
|
|
console.log(res);
|
|
}
|
|
});
|
|
},
|
|
onClose() {
|
|
this.setData({
|
|
showPopup: false
|
|
});
|
|
},
|
|
offshow() {
|
|
this.setData({
|
|
showPopup: false
|
|
});
|
|
},
|
|
getData() {
|
|
var that = this;
|
|
let urlStr = app.getNetAddresss("plugin.article-pay.api.index.articlePayData");
|
|
urlStr += "&id=" + this.data.id;
|
|
urlStr += "&art=detail";
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
success: function(resdata) {
|
|
var res = resdata.data;
|
|
console.log(res);
|
|
var time = utils.formatTimeTwo(res.data.payDetail.virtual_created_at, 'Y,M,D').replace(/,/g, ".");
|
|
that.setData({
|
|
dataInfo: res.data.payDetail,
|
|
is_time: time
|
|
});
|
|
},
|
|
fail: function(res) {
|
|
console.log(res);
|
|
}
|
|
});
|
|
},
|
|
getPayData() {
|
|
var that = this;
|
|
let urlStr = app.getNetAddresss("plugin.article-pay.api.index.getPayType");
|
|
app._getNetWork({
|
|
url: urlStr,
|
|
success: function(resdata) {
|
|
var res = resdata.data;
|
|
that.setData({
|
|
buttons: res.data.buttons
|
|
});
|
|
},
|
|
fail: function(res) {
|
|
console.log(res);
|
|
}
|
|
});
|
|
},
|
|
});
|