123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223 |
- // pages/my/experience/experience.js
- const App = getApp()
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- expertId: null,
- meetId: null,
- memberId: null,
- topicId: null,
- content: null,
- user: wx.getStorageSync('USER'),
- isAnonymous: false,
- checked: false,
- list: [],
- picture: '',
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- console.log(options)
- this.setData({
- meetId: options.meetId,
- expertId: options.expertId,
- topicId: options.topicId,
- memberId: options.memberId
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- },
- change(e) {
- if (e.detail.value.length > 0) {
- this.setData({
- isAnonymous: true
- })
- } else {
- this.setData({
- isAnonymous: false
- })
- }
- },
- submit() {
- if (!this.data.content) {
- wx.showToast({
- icon: 'none',
- title: '心得感受不能为空',
- })
- return false
- }
- App._post_form('meetevaluation/shareExperience', '', {
- content: this.data.content,
- expertId: this.data.expertId,
- id: this.data.user.id,
- meetId: this.data.meetId,
- isAnonymous: this.data.isAnonymous == true ? 1 : 0,
- memberId: this.data.user.id,
- picture: this.data.list.join(','),
- topicId: this.data.topicId
- }, res => {
- if (res.code === 0) {
- wx.showToast({
- title: '分享心得成功',
- })
- setTimeout(() =>{
- wx.switchTab({
- url: '/pages/home/index/index',
- })
- },2000)
-
- }
- })
- },
- uploadHandle() {
- if (this.data.list.length == 6) {
- return false
- }
- let _this = this;
- var tempFile;
- wx.showActionSheet({
- itemList: ['拍照上传', '从相册中选择'],
- success(res) {
- if (res.tapIndex === 0) {
- wx.chooseImage({
- count: 1,
- sizeType: ['original', 'compressed'],
- sourceType: ['camera'],
- success(res) {
- const tempFilePaths = res.tempFilePaths
- wx.uploadFile({
- url: App.apiRoot + 'file/upload',
- filePath: tempFilePaths[0],
- name: 'file',
- success: function (res) {
- if (res.errMsg === "uploadFile:ok") {
- wx.showToast({
- title: '上传成功',
- image: '',
- duration: 1500,
- mask: false
- });
- let data = JSON.parse(res.data)
- let imglist = _this.data.list
- imglist.push(data.data)
- _this.setData({
- list: imglist
- })
- }
- },
- function () {
- wx.showToast({
- title: '上传失败',
- icon: 'none',
- image: '',
- duration: 1500,
- mask: false,
- });
- }
- })
- }
- })
- } else if (res.tapIndex === 1) {
- wx.chooseImage({
- count: 1,
- sizeType: ['original', 'compressed'],
- sourceType: ['album'],
- success(res) {
- const tempFilePaths = res.tempFilePaths
- wx.uploadFile({
- url: App.apiRoot + 'file/upload',
- filePath: tempFilePaths[0],
- name: 'file',
- success: function (res) {
- if (res.errMsg === "uploadFile:ok") {
- wx.showToast({
- title: '上传成功',
- image: '',
- duration: 1500,
- mask: false
- });
- let data = JSON.parse(res.data)
- let imglist = _this.data.list
- imglist.push(data.data)
- _this.setData({
- list: imglist
- })
- }
- },
- function () {
- wx.showToast({
- title: '上传失败',
- icon: 'none',
- image: '',
- duration: 1500,
- mask: false,
- success: (result) => {},
- fail: () => {},
- complete: () => {}
- });
- }
- })
- }
- })
- }
- },
- fail(res) {}
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|