123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209 |
- <template>
- <view class="container">
- <view class="detail-desc">
- <view class="cu-bar bg-white ">
- <view class="action">
- 库点照片
- </view>
- </view>
- <view class="cu-form-group">
- <view class="grid col-2 grid-square flex-sub">
- <view class="bg-img" v-if="storeImg != ''" @tap="ViewImage" :data-url="storeImg">
- <image :src="storeImg" mode="aspectFit"></image>
- <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="0" >
- <text class='cuIcon-close'></text>
- </view>
- </view>
- <view class="solids" @tap="ChooseImage" v-if="storeImg == ''">
- <text class='cuIcon-cameraadd'></text>
- </view>
- </view>
- </view>
- <view class="cu-bar bg-white ">
- <view class="action">
- 粮食照片
- </view>
- </view>
- <view class="cu-form-group">
- <view class="grid col-2 grid-square flex-sub">
- <view class="bg-img" v-if="foodsImg != ''" @tap="ViewImage" :data-url="foodsImg">
- <image :src="foodsImg" mode="aspectFit"></image>
- <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="1" >
- <text class='cuIcon-close'></text>
- </view>
- </view>
- <view class="solids" @tap="ChooseImage2" v-if="foodsImg == ''">
- <text class='cuIcon-cameraadd'></text>
- </view>
- </view>
- </view>
- <view class="cu-bar bg-white ">
- <view class="action">
- 装车现场照片
- </view>
- </view>
- <view class="cu-form-group">
- <view class="grid col-2 grid-square flex-sub">
- <view class="bg-img" v-if="carImg != ''" @tap="ViewImage" :data-url="carImg">
- <image :src="carImg" mode="aspectFit"></image>
- <view class="cu-tag bg-red" @tap.stop="DelImg" :data-index="2">
- <text class='cuIcon-close'></text>
- </view>
- </view>
- <view class="solids" @tap="ChooseImage3" v-if="carImg == ''">
- <text class='cuIcon-cameraadd'></text>
- </view>
- </view>
- </view>
- </view>
- <view class="page-bottom">
- <view class="action-btn-group">
- <button type="primary" class=" action-btn no-border add-cart-btn" @click="finish">确认上传</button>
- </view>
- </view>
- </view>
- </template>
- <script>
- import uploadImage from '@/components/ossutil/uploadFile.js';
- export default {
- data(){
- return{
- userId:'',
- storeImg:'',
- foodsImg:'',
- carImg:'',
- id:''
- };
- },
- onLoad(tmp){
- this.id = tmp.id
- this.loadData()
- },
- onPullDownRefresh() {
- this.loadData()
- },
- methods: {
- loadData(){
-
- },
- ChooseImage() {
- uni.chooseImage({
- count: 1, //默认9
- sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
- sourceType: ['album','camera'], //从相册选择
- success: (res) => {
- //上传图片
- //图片路径可自行修改
- uploadImage(res.tempFilePaths[0], 'storeImg/',
- result => {
- this.storeImg = result
- uni.hideLoading();
- }
- )
- }
- });
- },
- ChooseImage2() {
- uni.chooseImage({
- count: 1, //默认9
- sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
- sourceType: ['album','camera'], //从相册选择
- success: (res) => {
- //上传图片
- //图片路径可自行修改
- uploadImage(res.tempFilePaths[0], 'foodsImg/',
- result => {
- this.foodsImg = result
- uni.hideLoading();
- }
- )
- }
- });
- },
- ChooseImage3() {
- uni.chooseImage({
- count: 1, //默认9
- sizeType: ['original', 'compressed'], //可以指定是原图还是压缩图,默认二者都有
- sourceType: ['album','camera'], //从相册选择
- success: (res) => {
- //上传图片
- //图片路径可自行修改
- uploadImage(res.tempFilePaths[0], 'carImg/',
- result => {
- this.carImg = result
- uni.hideLoading();
- }
- )
- }
- });
- },
- ViewImage(e) {
- var img = [];
- img = e.currentTarget.dataset.url.split(' ')
- uni.previewImage({
- current:0,
- urls: img
- });
- },
- DelImg(e) {
- uni.showModal({
- title: '提示',
- content: '确定要删除该照片吗?',
- cancelText: '取消',
- confirmText: '确定',
- success: res => {
- if (res.confirm) {
- if(e.currentTarget.dataset.index == 0){
- this.storeImg = "";
- }
- else if(e.currentTarget.dataset.index == 1){
- this.foodsImg = "";
- }
- else if(e.currentTarget.dataset.index == 2){
- this.carImg = "";
- }
- }
- }
- })
- },
- finish(){
- const that = this
- if(!that.storeImg){
- this.$api.msg('请上传库点照片');
- return;
- }
- if(!that.foodsImg){
- this.$api.msg('请上传粮食照片');
- return;
- }
- if(!that.carImg){
- this.$api.msg('请上传装车现场照片');
- return;
- }
- uni.showLoading({
- title: '正在提交',
- mask:true
- })
- that.$api.request('sale', 'addImg', {
- id:that.id,
- storeImg:that.storeImg,
- foodsImg:that.foodsImg,
- carImg:that.carImg,
-
- }, failres => {
- that.$api.msg(failres.errmsg)
- uni.hideLoading()
- }).then(res => {
- that.$api.msg('上传成功')
- setTimeout(()=>{uni.navigateBack({})},1000);
- uni.hideLoading()
- })
- },
-
- },
- }
- </script>
- <style>
- </style>
|