parent
c7323c1900
commit
83d81031e3
|
@ -1,19 +1,19 @@
|
|||
|
||||
let domain = 'http://apif.java.crmeb.net'
|
||||
// let domain = 'http://apif.java.crmeb.net'
|
||||
let domain = 'http://127.0.0.1:48080'
|
||||
|
||||
module.exports = {
|
||||
// 请求域名 格式: https://您的域名
|
||||
// #ifdef MP
|
||||
HTTP_REQUEST_URL: domain,
|
||||
// #endif
|
||||
HTTP_ADMIN_URL:'http://apif.java.crmeb.net', //PC后台的API请求地址,上传图片用
|
||||
// #ifdef H5
|
||||
//H5接口是浏览器地址
|
||||
// HTTP_REQUEST_URL: window.location.protocol+"//"+window.location.host,
|
||||
// http://api.java.crmeb.net:20001
|
||||
HTTP_REQUEST_URL:domain,
|
||||
HTTP_REQUEST_URL: domain,
|
||||
// #endif
|
||||
|
||||
|
||||
HEADER:{
|
||||
'content-type': 'application/json'
|
||||
},
|
||||
|
|
|
@ -33,11 +33,11 @@
|
|||
<view class='textarea'>
|
||||
<textarea placeholder='商品满足你的期待么?说说你的想法,分享给想买的他们吧~' name="comment" placeholder-class='placeholder'></textarea>
|
||||
<view class='list acea-row row-middle'>
|
||||
<view class='pictrue' v-for="(item,index) in picsPath" :key="index">
|
||||
<image :src='item'></image>
|
||||
<text class='iconfont icon-guanbi1' @click='DelPic(index)'></text>
|
||||
<view class='pictrue' v-for="(item,index) in pics" :key="index">
|
||||
<image :src='item' />
|
||||
<text class='iconfont icon-guanbi1' @click='DelPic(index)' />
|
||||
</view>
|
||||
<view class='pictrue acea-row row-center-wrapper row-column' @click='uploadpic' v-if="picsPath.length <= 8">
|
||||
<view class='pictrue acea-row row-center-wrapper row-column' @click='uploadpic' v-if="pics.length < 9">
|
||||
<text class='iconfont icon-icon25201'></text>
|
||||
<view>上传图片</view>
|
||||
</view>
|
||||
|
@ -59,7 +59,6 @@
|
|||
data() {
|
||||
return {
|
||||
pics: [],
|
||||
picsPath: [],
|
||||
scoreList: [{
|
||||
name: "商品质量",
|
||||
stars: ["", "", "", "", ""],
|
||||
|
@ -119,24 +118,15 @@
|
|||
* 删除图片
|
||||
*/
|
||||
DelPic: function(index) {
|
||||
this.picsPath.splice(index, 1);
|
||||
this.pics.splice(index, 1);
|
||||
},
|
||||
/**
|
||||
* 上传文件
|
||||
*/
|
||||
uploadpic: function() {
|
||||
let that = this;
|
||||
that.$util.uploadImageOne({
|
||||
url: 'user/upload/image',
|
||||
name: 'multipart',
|
||||
model: "product",
|
||||
pid: 1
|
||||
}, function(res) {
|
||||
that.pics.push(res.data.url);
|
||||
that.picsPath.push(res.data.localPath);
|
||||
that.$set(that, 'pics', that.pics);
|
||||
that.$set(that, 'picsPath', that.picsPath);
|
||||
this.$util.uploadImageOne({}, res => {
|
||||
this.pics.push(res.data);
|
||||
this.$set(this, 'pics', this.pics);
|
||||
});
|
||||
},
|
||||
|
||||
|
|
|
@ -1,14 +1,10 @@
|
|||
import {
|
||||
TOKENNAME,
|
||||
HTTP_REQUEST_URL
|
||||
} from '../config/app.js';
|
||||
import {HTTP_ADMIN_URL} from '@/config/app.js';
|
||||
import { TOKENNAME } from '../config/app.js';
|
||||
import { HTTP_REQUEST_URL } from '@/config/app.js';
|
||||
import store from '../store';
|
||||
import {
|
||||
pathToBase64
|
||||
} from '@/plugin/image-tools/index.js';
|
||||
|
||||
export default {
|
||||
/**
|
||||
|
||||
/**
|
||||
* opt object | string
|
||||
* to_url object | string
|
||||
* 例:
|
||||
|
@ -438,10 +434,7 @@ export default {
|
|||
let count = opt.count || 1,
|
||||
sizeType = opt.sizeType || ['compressed'],
|
||||
sourceType = opt.sourceType || ['album', 'camera'],
|
||||
inputName = opt.name || 'pics',
|
||||
pid = opt.pid,
|
||||
model = opt.model;
|
||||
|
||||
inputName = opt.name || 'file';
|
||||
uni.chooseImage({
|
||||
count: count, //最多可以选择的图片总数
|
||||
sizeType: sizeType, // 可以指定是原图还是压缩图,默认二者都有
|
||||
|
@ -451,7 +444,7 @@ export default {
|
|||
uni.showLoading({
|
||||
title: '图片上传中',
|
||||
});
|
||||
let urlPath = HTTP_ADMIN_URL + '/api/admin/upload/image' + "?model=" + model + "&pid=" + pid
|
||||
const urlPath = HTTP_REQUEST_URL + '/app-api/infra/file/upload'
|
||||
let localPath = res.tempFilePaths[0];
|
||||
uni.uploadFile({
|
||||
url: urlPath,
|
||||
|
@ -462,7 +455,10 @@ export default {
|
|||
// #ifdef MP
|
||||
"Content-Type": "multipart/form-data",
|
||||
// #endif
|
||||
[TOKENNAME]: store.state.app.token
|
||||
|
||||
// TODO 芋艿:后续改成动态读取,不要写死
|
||||
'tenant-id': 1,
|
||||
'Authorization': 'Bearer test247'
|
||||
},
|
||||
success: function(res) {
|
||||
uni.hideLoading();
|
||||
|
@ -472,8 +468,8 @@ export default {
|
|||
});
|
||||
} else {
|
||||
let data = res.data ? JSON.parse(res.data) : {};
|
||||
if (data.code === 200) {
|
||||
data.data.localPath = localPath;
|
||||
if (data.code === 200 || data.code === 0) {
|
||||
// data.data.localPath = localPath;
|
||||
successCallback && successCallback(data)
|
||||
} else {
|
||||
errorCallback && errorCallback(data);
|
||||
|
@ -490,14 +486,6 @@ export default {
|
|||
});
|
||||
}
|
||||
})
|
||||
// pathToBase64(res.tempFilePaths[0])
|
||||
// .then(imgBase64 => {
|
||||
// console.log(imgBase64);
|
||||
|
||||
// })
|
||||
// .catch(error => {
|
||||
// console.error(error)
|
||||
// })
|
||||
}
|
||||
})
|
||||
},
|
||||
|
|
Loading…
Reference in New Issue