From 3550babe49f176c1aa740dd5853ccb52e5947e9d Mon Sep 17 00:00:00 2001 From: wangfukang <15630117759@163.com> Date: Wed, 11 Nov 2026 15:40:34 +0800 Subject: [PATCH] 1 --- pages/index/index.vue | 9 +++ pages/shop/addGoods.vue | 143 ++++++++++++++++++++++------------- pages/shop/shopOrderList.vue | 5 +- 3 files changed, 104 insertions(+), 53 deletions(-) diff --git a/pages/index/index.vue b/pages/index/index.vue index 07a3fa3..95ea0d8 100644 --- a/pages/index/index.vue +++ b/pages/index/index.vue @@ -296,6 +296,7 @@ onShow() { if(!uni.getStorageSync('peisongyuan')){ this.indexInit() + this.refreshOrderListAfterMeal() } }, onLoad() { @@ -313,6 +314,14 @@ }, methods: { + refreshOrderListAfterMeal() { + if (!uni.getStorageSync('refreshShopOrderList')) return + this.$nextTick(() => { + if (!this.$refs.deLivery || !this.$refs.deLivery.init) return + uni.removeStorageSync('refreshShopOrderList') + this.$refs.deLivery.init() + }) + }, indexInit() { let that = this this.shopConfig = JSON.parse(uni.getStorageSync('area')) || {} diff --git a/pages/shop/addGoods.vue b/pages/shop/addGoods.vue index a8d2edc..a6d71ff 100644 --- a/pages/shop/addGoods.vue +++ b/pages/shop/addGoods.vue @@ -139,7 +139,7 @@ :adjust-position="false" :cursor-spacing="160" @focus="focusFormField('startPayNumField')" @blur="blurFormField"> - + { + this.settingEditor = false + }, 300) + }, + syncProductIntro() { + return new Promise((resolve) => { + if (!this.editorIns || typeof this.editorIns.getContents !== 'function') { + resolve() + return + } + this.editorIns.getContents({ + success: (res) => { + const html = res && res.html ? res.html : '' + if (html || this.editorTouched) { + this.formData.productIntro = html + } + resolve() + }, + fail: () => resolve() + }) + }) }, /** * 直接运行示例工程插入图片无法正常显示的看这里 @@ -352,53 +389,51 @@ * @param {Object} editorCtx */ upinImage(tempFiles, editorCtx) { - /** - * 本地临时插入图片预览 - * 注意:这里仅是示例本地图片预览,因为需要将图片先上传到云端,再将图片插入到编辑器中 - * 正式开发时,还请将此处注释,并解开下面 使用 uniCloud.uploadFile 上传图片的示例方法 的注释 - * @tutorial https://uniapp.dcloud.net.cn/api/media/editor-context.html#editorcontext-insertimage - */ - // #ifdef MP-WEIXIN - // 注意微信小程序的图片路径是在tempFilePath字段中 - editorCtx.insertImage({ - src: tempFiles[0].tempFilePath, - width: '80%', // 默认不建议铺满宽度100%,预留一点空隙以便用户编辑 - success: function() {} - }) - // #endif - - // #ifndef MP-WEIXIN - editorCtx.insertImage({ - src: tempFiles[0].path, - width: '80%', // 默认不建议铺满宽度100%,预留一点空隙以便用户编辑 - success: function() {} + const files = Array.isArray(tempFiles) ? tempFiles : [] + files.forEach((item) => { + const filePath = item.tempFilePath || item.path + if (!filePath) return + uni.showLoading({ + title: '上传中', + mask: true + }) + uni.uploadFile({ + url: getApp().globalData.mainurl + '/upload/file', + filePath: filePath, + name: 'file', + header: { + "content-type": "multipart/form-data", + 'accessToken': uni.getStorageSync("hiver_token") + }, + success: (uploadFileRes) => { + uni.hideLoading() + let pathData = {} + try { + pathData = JSON.parse(uploadFileRes.data || '{}') + } catch (e) { + pathData = {} + } + if (!pathData.result) { + uni.showToast({ + title: pathData.message || '图片上传失败', + icon: 'none' + }) + return + } + editorCtx.insertImage({ + src: pathData.result, + width: '80%' + }) + }, + fail: () => { + uni.hideLoading() + uni.showToast({ + title: '图片上传失败', + icon: 'none' + }) + } + }) }) - // #endif - - /** - * 使用 uniCloud.uploadFile 上传图片的示例方法(可适用多选上传) - * 正式开发环境中,请将上面 本地临时插入图片预览 注释后,模仿以下写法 - */ - // tempFiles.forEach(async (item) => { - // uni.showLoading({ - // title: '上传中请稍后', - // mask: true - // }) - // let upfile = await uniCloud.uploadFile({ - // filePath: item.path, - // // 同名会导致报错 policy_does_not_allow_file_overwrite - // // cloudPath可由 想要存储的文件夹/文件名 拼接,若不拼文件夹名则默认存储在cloudstorage文件夹中 - // cloudPath: `cloudstorage/${item.name}`, - // cloudPathAsRealPath: true - // }) - // editorCtx.insertImage({ - // src: upfile.fileID, - // width: '80%', // 默认不建议铺满宽度100%,预留一点空隙以便用户编辑 - // success: function () { - // uni.hideLoading() - // } - // }) - // }) }, //跳转分类页 goGategoryLow() { @@ -457,7 +492,7 @@ } }, // 触发提交表单 - submit() { + async submit() { let that = this; this.syncLunchBoxByMoreBuy() if (!this.validateRequiredProductFields()) { @@ -472,6 +507,7 @@ if (!this.validateGroupBuyPrices()) { return } + await this.syncProductIntro() // this.$refs.form.validate((valid) => { // if (valid) { if (this.modalType == 0) { @@ -925,6 +961,7 @@ if (!this.isMoreBuyEnabled()) { this.getMoreBuyProductOptions() } + this.setEditorContent(this.formData.productIntro) this.modalVisible = true; }, checkSpecValue(index){ @@ -1418,8 +1455,10 @@ } .xiangxi-box{ flex: 1; + height: 560rpx; border: 1px solid #eee; border-radius: 20rpx; + overflow: hidden; } .left-box { width: 100%; diff --git a/pages/shop/shopOrderList.vue b/pages/shop/shopOrderList.vue index 7fdb8f5..d706090 100644 --- a/pages/shop/shopOrderList.vue +++ b/pages/shop/shopOrderList.vue @@ -165,7 +165,10 @@ } }, onShow() { - + if (!uni.getStorageSync('refreshShopOrderList')) return + uni.removeStorageSync('refreshShopOrderList') + this.searchForm.pageNum = 1 + this.getList() }, onLoad(option) { if(option.index){