对表白墙js文件的解释

index.js

  1 Page({
  2 
  3     /**
  4      * 页面的初始数据
  5      */
  6     data: {
  7       xcx_appid:"",
  8     },
  9     HuoquDaohangLiebiao(){
 10       var that = this
 11       wx.request({
 12         url: 'https://xx.uom.cn/ecmsapi/index.php?mod=xinxi&act=xinxizhanshijiekou',
 13         method:"POST",
 14         data:{
 15           xcx_appid:this.data.xcx_appid
 16         },
 17         header: {
 18           'content-type': 'application/x-www-form-urlencoded'
 19         },
 20         success:(res)=>{
 21           console.log("信息",res);
 22           that.setData({
 23             xinwen:res.data.list,
 24             xcx_appid:this.data.xcx_appid,
 25           })
 26         }
 27       })
 28     },
 29   
 30   //   跳转到详情
 31   QuXiangqing:function(e){
 32   console.log(e)
 33   let id = e.currentTarget.dataset.id
 34   wx.navigateTo({
 35     url: '/pages/xiangqing/xiangqing?id='+id,
 36   })
 37   },
 38 //   获取小程序appid
 39   HuoquXiaochengxuAppId(){
 40     var that=this;
 41     var xcx_appid=this.data.xcx_appid;
 42     const accountInfo = wx.getAccountInfoSync();
 43           console.log("小程序id",accountInfo.miniProgram.appId); //小程序id
 44           that.setData({
 45           xcx_appid:accountInfo.miniProgram.appId,
 46           });
 47           xcx_appid=accountInfo.miniProgram.appId,
 48           console.log(xcx_appid);
 49   },
 50 //   跳转到发布页
 51   QuFabu:function(){
 52     wx.navigateTo({
 53       url: '/pages/fabu/fabu',
 54     })
 55   },
 56     /**
 57      * 生命周期函数--监听页面加载
 58      */
 59     onLoad(options) {//当页面加载时加载的内容
 60         this.HuoquXiaochengxuAppId();
 61             var jiage
 62             var that = this
 63             console.log("打印",options.lanmu)
 64             let lanmu = options.lanmu
 65             console.log("信息测试",lanmu);
 66             wx.request({
 67               url: 'https://xx.uom.cn/ecmsapi/index.php?mod=daohanglan&act=silanneirongliebiao',
 68               method:"POST",
 69               data:{
 70                 lanmu:"信息问答",
 71                 xcx_appid:"wx7c24e1e2e2875b2e"
 72               },        
 73           
 74               method:"POST",
 75               header: {
 76                 'content-type': 'application/x-www-form-urlencoded'
 77               },
 78               success:(res)=>{
 79                 console.log("信息",res);
 80                 lanmu=res.data.lanmu,
 81                
 82                 that.setData({
 83                   yhxinxi:res.data.list,
 84                  
 85                 })
 86               }
 87             })
 88         
 89     },//xcx_appid:小程序的appid,yhxinxi:用户信息,lanmu:栏目
 90   
 91     /**
 92      * 生命周期函数--监听页面初次渲染完成
 93      */
 94     onReady() {
 95   
 96     },
 97   
 98     /**
 99      * 生命周期函数--监听页面显示
100      */
101     onShow() {
102   
103     },
104   
105     /**
106      * 生命周期函数--监听页面隐藏
107      */
108     onHide() {
109   
110     },
111   
112     /**
113      * 生命周期函数--监听页面卸载
114      */
115     onUnload() {
116   
117     },
118   
119     /**
120      * 页面相关事件处理函数--监听用户下拉动作
121      */
122     onPullDownRefresh() {
123   
124     },
125   
126     /**
127      * 页面上拉触底事件的处理函数
128      */
129     onReachBottom() {
130   
131     },
132   
133     /**
134      * 用户点击右上角分享
135      */
136     onShareAppMessage() {
137   
138     }
139   })

xiangqing.js

 1 // pages/xiangqing/xiangqing.js
 2 Page({
 3 
 4     /**
 5      * 页面的初始数据
 6      */
 7     data: {
 8   
 9     },
10 
11     /**
12      * 生命周期函数--监听页面加载
13      */
14     onLoad(options) {
15         var that=this;
16       console.log("打印id",options.id)
17       let id = options.id
18       wx.request({
19         url: 'https://xx.uom.cn/ecmsapi/index.php?mod=daohanglan&act=silanneirongxiangqing',
20         data:{
21             id:id,
22         },
23         method:"POST",
24         header: {
25           'content-type': 'application/x-www-form-urlencoded'
26         },
27         success:(res)=>{
28           console.log("信息",res);
29           that.setData({
30             id:res.data.id,
31             biaoti:res.data.list[0].title,
32             jiage:res.data.list[0].jiage,
33             chengse:res.data.list[0].chengse,
34             neirong:res.data.list[0].neirong,
35             lianxi:res.data.list[0].lianxi,
36             tupian1:res.data.list[0].tupian1,
37             tupian2:res.data.list[0].tupian2,
38             tupian3:res.data.list[0].tupian3
39           })
40 
41         }
42       })
43     },
44   
45     /**
46      * 生命周期函数--监听页面初次渲染完成
47      */
48     onReady() {
49   
50     },
51   
52     /**
53      * 生命周期函数--监听页面显示
54      */
55     onShow() {
56   
57     },
58   
59     /**
60      * 生命周期函数--监听页面隐藏
61      */
62     onHide() {
63   
64     },
65   
66     /**
67      * 生命周期函数--监听页面卸载
68      */
69     onUnload() {
70   
71     },
72   
73     /**
74      * 页面相关事件处理函数--监听用户下拉动作
75      */
76     onPullDownRefresh() {
77   
78     },
79   
80     /**
81      * 页面上拉触底事件的处理函数
82      */
83     onReachBottom() {
84   
85     },
86   
87     /**
88      * 用户点击右上角分享
89      */
90     onShareAppMessage() {
91   
92     }
93   })

fabu.js

  1 // pages/fabuxinxi/fabuxinxi.js
  2 Page({
  3 
  4     /**
  5      * 页面的初始数据
  6      */
  7     data: {
  8       flag:true,
  9       index:-1,
 10       lanmuliebiao:['交易市场','失物招领','信息问答','美味分享',],
 11       tupianliebiao:[],
 12       tpdzlb:[],
 13       xcx_appid:"",
 14     },
 15     //获取小程序appid
 16     HuoquXiaochengxuAppId(){
 17       var that=this;
 18       var xcx_appid=this.data.xcx_appid;
 19       const accountInfo = wx.getAccountInfoSync();
 20             console.log("小程序id",accountInfo.miniProgram.appId); //小程序id
 21             that.setData({
 22             xcx_appid:accountInfo.miniProgram.appId,
 23             });
 24             xcx_appid="accountInfo.miniProgram.appId",
 25             console.log(xcx_appid);
 26     },
 27     // 上传图片
 28     uploadImage(){
 29       var that=this;
 30       var tupiandizhi;
 31       var tupianliebiao=this.data.tupianliebiao
 32       var tpdzlb=this.data.tpdzlb;
 33       wx.chooseMedia({
 34         count: 1,
 35         mediaType: ['image'],
 36         sourceType: ['album', 'camera'],
 37         maxDuration: 30,
 38         camera: 'back',
 39         success: function(res){
 40           console.log("得到的信息1",res.tempFiles[0].tempFilePath);
 41           tupiandizhi=res.tempFiles[0].tempFilePath;
 42           tupianliebiao.push(tupiandizhi)
 43           that.setData({
 44             // 返回给页面展示信息
 45             tl:tupianliebiao
 46           })
 47           console.log("得到的信息2",tupianliebiao);
 48           wx.uploadFile({
 49             
 50             filePath: tupiandizhi,
 51             name: 'imgfile',
 52             url: 'https://xx.uom.cn/ecmsapi/index.php?mod=xinxi&act=tupianshangchuan&xcx_appid=wx7c24e1e2e2875b2e',
 53             success(res){
 54               console.log("得到的信息3",res.data)
 55               tpdzlb.push(res.data)
 56               console.log("得到的信息4",tpdzlb)
 57             }
 58           })
 59         }
 60       })
 61     },
 62     // 上传表单信息
 63     formshangchuan: function (e) {
 64       var that = this
 65       console.log('点击了上传',e.detail.value);
 66       
 67       wx.request({
 68         url: 'https://xx.uom.cn/ecmsapi/index.php?mod=xinxi&act=yonghushangchuanxinxi',
 69         method:'POST',
 70         data:{
 71           xcx_appid:"wx7c24e1e2e2875b2e",
 72           sclanmu:"信息问答",//栏目
 73           scbiaoti:"表白墙",//标题
 74           scneirong:e.detail.value.neirong,//内容
 75           sctupiandz1:this.data.tpdzlb[0],//图片地址1
 76           sctupiandz2:this.data.tpdzlb[1],//图片地址2
 77           sctupiandz3:this.data.tpdzlb[2],//图片地址3
 78           yonghuid:"Lee",
 79         },
 80         header: {
 81           'content-type': 'application/x-www-form-urlencoded'
 82         },
 83         success (res) {
 84           console.log("返回的数据",res.data);
 85           var tishi = res.data.message;
 86           that.setData({
 87             tishi:"提示:"+tishi+"!"
 88           })
 89         }
 90         
 91       })
 92       if(e.detail.value.neirong!=""){
 93           wx.redirectTo({
 94             url: '/pages/index/index',
 95             })
 96       }
 97     },
 98       // 渲染列表
 99       xuanlanmuliebiao:function(e){
100          console.log(e)
101         this.setData({
102           index:e.detail.value
103         })
104       },
105       // 重置按钮
106       chongzhi:function(){
107         wx.redirectTo({
108           url: '/pages/fabu/fabu',
109         })},
110     /**
111      * 生命周期函数--监听页面加载
112      */
113     onLoad(options) {
114       this.HuoquXiaochengxuAppId();
115     },
116   
117     onReady() {
118   
119     },
120   
121     /**
122      * 生命周期函数--监听页面显示
123      */
124     onShow() {
125   
126     },
127   
128     /**
129      * 生命周期函数--监听页面隐藏
130      */
131     onHide() {
132   
133     },
134   
135     /**
136      * 生命周期函数--监听页面卸载
137      */
138     onUnload() {
139   
140     },
141   
142     /**
143      * 页面相关事件处理函数--监听用户下拉动作
144      */
145     onPullDownRefresh() {
146   
147     },
148   
149     /**
150      * 页面上拉触底事件的处理函数
151      */
152     onReachBottom() {
153   
154     },
155   
156     /**
157      * 用户点击右上角分享
158      */
159     onShareAppMessage() {
160   
161     }
162   })

 

posted @ 2022-09-07 14:08  遇见lilanglang  阅读(72)  评论(0)    收藏  举报