123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157 |
- // pages/details/details.js
- var app = getApp();
- Page({
- data: {
- info: null,
- id: 129,
- remmondList: [],
- isShow: false,
- initPerid: null,
- loanMoney: 0,
- money: 0,
- time: 0,
- valLoan: 0,
- index: 0,
- hiddenThis: true,
- appid: 0
- },
- onLoad: function (options) {
- var id = options.id, tmplmsg = options.tmplmsg || 0;
- if (id) {
- this.setData({id: id})
- }
- this.initDetails(tmplmsg);
- this.getRemmondList();
- // this.showConcact(null, true);
- // console.log(this.data.remmondList);
- },
- bindPickerChange: function(e) {
- var that = this, time = 0, idx = e.detail.value ;
- time = that.data.initPerid[idx].k
- this.setData({
- index: e.detail.value,
- time: parseFloat(time)
- })
- that.caculateMoney();
- // console.log(time);
- },
- initDetails (tmplmsg) {
- var that = this, data = null;
- wx.request({
- url: app.globalData.HOST + '/user/product/detail',
- method: "POST",
- data: Object.assign({}, app.globalData.common, {id: that.data.id, tmplmsg: tmplmsg}),
- success: function (res) {
- if (res.data.errno == '0') {
- data = res.data.rst;
- }
- that.setData({ info: data, initPerid: data.loan_period, money: data.upper_amount, time: data.loan_period[0].k, rate: data.day_rate});
- that.caculateMoney()
- },
- complete: function () {
- // that.setData({ hidden:true});//加载成功
- wx.stopPullDownRefresh() //停止下拉刷新
- }
- });
- },
- getRemmondList () {
- var that = this, list = [];
- wx.request({
- url: app.globalData.HOST + '/user/product/getSameAmountByProductId',
- method: "POST",
- data: Object.assign({}, app.globalData.common, {id: that.data.id, platform: app.globalData.platform}),
- success: function (res) {
- if (res.data.errno == '0') {
- list = res.data.rst.data;
- }
- that.setData({ remmondList: list});
- },
- complete: function () {
- // that.setData({ hidden:true});//加载成功
- wx.stopPullDownRefresh() //停止下拉刷新
- }
- });
- },
- showMore () {
- var that = this;
- that.setData({isShow: !that.data.isShow})
- },
- goRemmond (event) {
- var id = event.currentTarget.dataset.id;
- wx.redirectTo({
- url: '/pages/details/details?id=' + id
- })
- // console.log(id);
- },
- caculateMoney () {
- var that = this, loanMoney = 0;
- var valLoan = that.data.money, rate = that.data.rate, time = that.data.time;
- // console.log(valLoan);
- // console.log(rate);
- console.log(time);
- loanMoney = valLoan + valLoan * rate * time / 100;
- // console.log(loanMoney);
- that.setData({loanMoney: loanMoney.toFixed(0)})
- },
- changeMoney (e) {
- var that = this;
- var money = e.detail.value, max = that.data.info.lower_amount, min = that.data.info.upper_amount;
- if (money < min) {
- money = min
- }else if(money > max){
- money = max
- }else{
- money = parseFloat(e.detail.value)
- }
- that.setData({money: money})
- that.caculateMoney();
- },
- showConcact (event) {
- var that = this;
- var tel = wx.getStorageSync('tel') || '0', user_id = wx.getStorageSync('user').user_id || '0', id = event.currentTarget.dataset.id;
- if (user_id != '0' || tel != '0') {
- // 绑定了手机号
- this.setData({hiddenThis: false, appid: id});
- wx.request({
- url: app.globalData.HOST + '/user/wx/known',
- method: "POST",
- data: Object.assign({}, app.globalData.common, {id: id}),
- success: function (res) {
- },
- complete: function () {
- }
- });
- }else{
- // 未绑定手机号
- wx.navigateTo({
- url: "/pages/getPhone/getPhone?from=details&preid=" + id
- })
- }
- },
- onReady: function () {
- },
- onShow: function () {
- },
- onHide: function () {
- this.setData({hiddenThis: true})
- },
- onUnload: function () {
- },
- //FormId
- formSubmit(e) {
- var formId = e.detail.formId;
- this.getFromid(formId);
- console.log(formId+"formID")
- },
- getFromid(formId) {
- wx.request({
- url: app.globalData.HOST + '/user/wx/getFromid',
- method: "POST",
- data: Object.assign({}, app.globalData.common, { from_id: formId }),
- success: function (res) {
- },
- complete: function () {
- }
- });
- }
- })
|