123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113 |
- const app = getApp()
- const $api = require('../../utils/api.js').API;
- Page({
-
- data: {
- today_stock_img:[]
- },
-
- onLoad: function (options) {
- },
- uploadImg() {
- var today_stock_img = this.data.today_stock_img;
- wx.chooseImage({
- success: res => {
- wx.showLoading({
- title: '正在上传',
- })
- const tempFilePaths = res.tempFiles
- for (let i = 0; i < tempFilePaths.length; i++) {
- $api.upload(tempFilePaths[i].path, 'file').then(res => {
- wx.hideLoading()
- if (res.code == 0) {
- today_stock_img.push(res.data.url)
- this.setData({
- today_stock_img: today_stock_img
- })
- } else {
- wx.showToast({
- title: '上传失败',
- })
- }
- })
- .catch(err => {
- wx.hideLoading()
- })
- }
-
- }
- })
- },
- del(e) {
- var i = e.target.dataset.id;
- var today_stock_img = this.data.today_stock_img;
- today_stock_img.splice(i, 1)
- this.setData({
- today_stock_img: today_stock_img
- })
- },
- prview(e){
- var src = e.target.dataset.src;
- wx.previewImage({
- current: src,
- urls: [src]
- })
- },
-
- onReady: function () {
- },
-
- onShow: function () {
- },
-
- onHide: function () {
- },
-
- onUnload: function () {
- },
-
- onPullDownRefresh: function () {
- },
-
- onReachBottom: function () {
- },
-
- onShareAppMessage: function () {
- }
- })
|