123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293 |
- // 引入 QCloud 小程序增强 SDK
- var qcloud = require('../../vendor/qcloud-weapp-client-sdk/index');
- // 引入配置
- var config = require('../../config');
- // 显示繁忙提示
- var showBusy = text => wx.showToast({
- title: text,
- icon: 'loading',
- duration: 10000
- });
- // 显示成功提示
- var showSuccess = text => {
- wx.hideToast();
- wx.showToast({
- title: text,
- icon: 'success'
- });
- };
- // 显示失败提示
- var showModel = (title, content) => {
- wx.hideToast();
- wx.showModal({
- title,
- content: JSON.stringify(content),
- showCancel: false
- });
- };
- //获取应用实例
- var app = getApp()
- Page({
- data: {
- "hash_key":"",
- "imageSrc":"",
- "text":""
- },
- onLoad: function (e) {
- console.log('onLoad');
- this.setData({
- hash_key:e.hash_key
- })
- },
- onShow: function () {
- console.log('onShow');
- var self=this
- qcloud.request({
- // 要请求的地址
- url: config.service.apiUrl+'messages/'+self.data.hash_key,
- success(result) {
- console.log(result);
- if(result.data.success==true){
- self.setData({
- text:result.data.message_data.text,
- imageSrc:result.data.message_data.image_url
- });
- }else{
- wx.redirectTo({
- url: '/pages/index/index'
- })
- }
- },
- fail(error) {
- console.log('request fail', error);
- },
- complete() {
- console.log('request complete');
- }
- });
- },
- edit:function(){
- wx.redirectTo({
- url: '/pages/add/add'
- })
- },
- send:function(){
- wx.redirectTo({
- url: '/pages/send/send'
- })
- },
- onShareAppMessage: function () {
- return {
- title: '密件',
- desc: '密件',
- path: 'pages/send/send?hash_key='+this.data.hash_key
- }
- }
- })
|