b_sms.js 1.44 KB
// pages/book/b_sms.js
var util = require('../../../utils/util.js')
import App from '../../../utils/api';
Page({

  /**
   * 页面的初始数据
   */
  tplsIndex: 'SMS_163050401',
  data: {
    bookInfo: {},
    tplMsg: ''
  },
  sc:{},
  /**
   * 生命周期函数--监听页面加载
   */
  onLoad: function (options) {
    this.options=options;
    this.enter_params=util.cache('enter_params');
    this.getDetail();
  },
  /**
   * 生命周期函数--监听页面初次渲染完成
   */
  onReady: function () {

  },

  /**
   * 生命周期函数--监听页面显示
   */
  onShow: function () {

  },

  /**
   * 生命周期函数--监听页面隐藏
   */
  onHide: function () {

  },

  /**
   * 生命周期函数--监听页面卸载
   */
  onUnload: function () {

  },
  bookInfo: null,
  async getDetail(){
    let msg=await App.SendSMS.GetSmsContent({rid: this.options.id});
    console.log('tplMsg',msg.data.content)
    this.setData({
      tplMsg: msg.data.content
    })
  },
  sendsms(){
    App.SendSMS.NewMessage({
      rid: this.options.id,
      sid:this.enter_params.seller_id,
    }).then(res=>{
      if (res.ret != 200) {
        return util.toast(res.msg, 'none');
      }
      util.toast('短信已发送');
      this.setData({
        hideSendsms: true,
      })
      App.Reserve.SmsInfo({seller_id: this.enter_params.seller_id}, 'clear')
    })
  },
  copysms(){
    wx.setClipboardData({
      data: this.data.tplMsg
    })
  },
})