123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199 |
- const app = getApp();
- const url = require('../../utils/const.js');
- const APIClient = require('../../utils/APIClient.js');
- const HOST = url.apiUrl;
- Page({
-
- data: {
- tempFilePath: [],
- imgId: [],
- textValue: ''
- },
-
- bindKeyInput: function(e) {
- this.setData({
- textValue: e.detail.value
- })
- },
-
- uploading: function () {
- var that = this;
- wx.chooseImage({
- count: 2,
- sizeType: ['compressed'],
- sourceType: ['album', 'camera'],
- success: function (res) {
-
- var tempFilePaths = res.tempFilePaths;
-
- wx.showToast({
- title: '正在上传...',
- icon: 'loading',
- mask: true,
- duration: 1000
- })
- that.setData({
- tempFilePath: tempFilePaths
- })
- var uploadImgCount = 0;
- for (var i = 0, h = tempFilePaths.length; i < h; i++) {
-
- wx.uploadFile({
- url: HOST + '/cms/file/upload',
- filePath: tempFilePaths[i],
- name: 'uploadfile_ant',
- header: {
- "Content-Type": "multipart/form-data"
- },
- success: function (res) {
- uploadImgCount++;
- let data = JSON.parse(res.data);
- let imgId = [];
- imgId.push(data.data.id)
- that.setData({
- imgId: imgId,
- })
- console.log(data);
-
- if (uploadImgCount == tempFilePaths.length) {
- wx.hideToast();
- }
- },
- fail: function (res) {
- wx.hideToast();
- wx.showModal({
- title: '错误提示',
- content: '上传图片失败',
- showCancel: false,
- success: function (res) { }
- })
- }
- });
- }
- }
- });
- },
-
- send: function() {
- let header = {
- uid: 'e7e0d43a-36b1-4e71-a3a3-61469c90d0a2'
- }
- if(this.data.imgId.length == 0){
- wx.showModal({
- title: '提示',
- content: '请上传分享的作品',
- success: function(res) {
- if (res.confirm) {
- console.log('用户点击确定')
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
- return false;
- }
- let data = {
- "title": this.data.textValue,
- "userId": "e7e0d43a-36b1-4e71-a3a3-61469c90d0a2",
- "type": "1",
- "columnId": "41209f14-05ba-11e8-9771-080027fcfc4b",
- "columnType": "6",
- "columnNames": "艺术",
- "imagesStrList": this.data.imgId
- };
- APIClient.getSendSchedule(header, data).success(res => {
- console.log(res);
- })
-
- },
-
- listenerButtonPreviewImage: function(e) {
- let index = e.target.dataset.index;
- let that = this;
- wx.previewImage({
- current: that.data.tempFilePath[index],
- urls: that.data.tempFilePath,
-
- success: function(res) {
-
- },
-
- fail: function() {
-
- }
- })
- },
-
- onLoad: function (options) {
-
- },
-
- onReady: function () {
-
- },
-
- onShow: function () {
-
- },
-
- onHide: function () {
-
- },
-
- onUnload: function () {
-
- },
-
- onPullDownRefresh: function () {
-
- },
-
- onReachBottom: function () {
-
- },
-
- onShareAppMessage: function () {
-
- }
- })
|