wangfukang 3 days ago
parent
commit
3550babe49
  1. 9
      pages/index/index.vue
  2. 143
      pages/shop/addGoods.vue
  3. 5
      pages/shop/shopOrderList.vue

9
pages/index/index.vue

@ -296,6 +296,7 @@
onShow() { onShow() {
if(!uni.getStorageSync('peisongyuan')){ if(!uni.getStorageSync('peisongyuan')){
this.indexInit() this.indexInit()
this.refreshOrderListAfterMeal()
} }
}, },
onLoad() { onLoad() {
@ -313,6 +314,14 @@
}, },
methods: { 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() { indexInit() {
let that = this let that = this
this.shopConfig = JSON.parse(uni.getStorageSync('area')) || {} this.shopConfig = JSON.parse(uni.getStorageSync('area')) || {}

143
pages/shop/addGoods.vue

@ -139,7 +139,7 @@
:adjust-position="false" :cursor-spacing="160" @focus="focusFormField('startPayNumField')" @blur="blurFormField"> :adjust-position="false" :cursor-spacing="160" @focus="focusFormField('startPayNumField')" @blur="blurFormField">
</uni-forms-item> </uni-forms-item>
</view> </view>
<uni-forms-item label="详细图文" name="startPayNum"> <uni-forms-item label="详细图文" name="productIntro">
<view class="xiangxi-box"> <view class="xiangxi-box">
<sp-editor <sp-editor
@init="initEditor" @init="initEditor"
@ -216,6 +216,9 @@
moreBuyProductOptions:[], moreBuyProductOptions:[],
scrollTarget:'', scrollTarget:'',
editorIns: null, editorIns: null,
editorReady: false,
editorTouched: false,
settingEditor: false,
typeItem: {}, typeItem: {},
shopMerchantType:0, shopMerchantType:0,
formData: { formData: {
@ -323,7 +326,13 @@
* @param {Object} e {html,text} 内容的html文本,和text文本 * @param {Object} e {html,text} 内容的html文本,和text文本
*/ */
inputOver(e) { inputOver(e) {
this.productIntro = e if (this.settingEditor) return
const html = e && typeof e === 'object' ? (e.html || '') : (e || '')
const text = e && typeof e === 'object' && e.text ? String(e.text).replace(/[\s\u00a0]/g, '') : ''
if (!this.editorReady && !html && !text) return
if (!html && !text && this.formData.productIntro && !this.editorTouched) return
this.editorTouched = true
this.formData.productIntro = html
}, },
/** /**
* 超出最大内容限制 * 超出最大内容限制
@ -340,9 +349,37 @@
* @tutorial 相关api https://uniapp.dcloud.net.cn/api/media/editor-context.html * @tutorial 相关api https://uniapp.dcloud.net.cn/api/media/editor-context.html
*/ */
initEditor(editor) { initEditor(editor) {
this.editorIns = editor // 保存编辑器实例 this.editorIns = editor
// 保存编辑器实例后,可以在此处获取后端数据,并赋值给编辑器初始化内容 this.editorReady = true
this.setEditorContent(this.formData.productIntro)
},
setEditorContent(html) {
if (!this.editorIns || html === undefined || html === null || html === '') return
this.settingEditor = true
this.editorIns.setContents({
html: html
})
setTimeout(() => {
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 * @param {Object} editorCtx
*/ */
upinImage(tempFiles, editorCtx) { upinImage(tempFiles, editorCtx) {
/** const files = Array.isArray(tempFiles) ? tempFiles : []
* 本地临时插入图片预览 files.forEach((item) => {
* 注意:这里仅是示例本地图片预览,因为需要将图片先上传到云端,再将图片插入到编辑器中 const filePath = item.tempFilePath || item.path
* 正式开发时,还请将此处注释,并解开下面 使用 uniCloud.uploadFile 上传图片的示例方法 的注释 if (!filePath) return
* @tutorial https://uniapp.dcloud.net.cn/api/media/editor-context.html#editorcontext-insertimage uni.showLoading({
*/ title: '上传中',
// #ifdef MP-WEIXIN mask: true
// 注意微信小程序的图片路径是在tempFilePath字段中 })
editorCtx.insertImage({ uni.uploadFile({
src: tempFiles[0].tempFilePath, url: getApp().globalData.mainurl + '/upload/file',
width: '80%', // 默认不建议铺满宽度100%,预留一点空隙以便用户编辑 filePath: filePath,
success: function() {} name: 'file',
}) header: {
// #endif "content-type": "multipart/form-data",
'accessToken': uni.getStorageSync("hiver_token")
// #ifndef MP-WEIXIN },
editorCtx.insertImage({ success: (uploadFileRes) => {
src: tempFiles[0].path, uni.hideLoading()
width: '80%', // 默认不建议铺满宽度100%,预留一点空隙以便用户编辑 let pathData = {}
success: function() {} 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() { goGategoryLow() {
@ -457,7 +492,7 @@
} }
}, },
// 触发提交表单 // 触发提交表单
submit() { async submit() {
let that = this; let that = this;
this.syncLunchBoxByMoreBuy() this.syncLunchBoxByMoreBuy()
if (!this.validateRequiredProductFields()) { if (!this.validateRequiredProductFields()) {
@ -472,6 +507,7 @@
if (!this.validateGroupBuyPrices()) { if (!this.validateGroupBuyPrices()) {
return return
} }
await this.syncProductIntro()
// this.$refs.form.validate((valid) => { // this.$refs.form.validate((valid) => {
// if (valid) { // if (valid) {
if (this.modalType == 0) { if (this.modalType == 0) {
@ -925,6 +961,7 @@
if (!this.isMoreBuyEnabled()) { if (!this.isMoreBuyEnabled()) {
this.getMoreBuyProductOptions() this.getMoreBuyProductOptions()
} }
this.setEditorContent(this.formData.productIntro)
this.modalVisible = true; this.modalVisible = true;
}, },
checkSpecValue(index){ checkSpecValue(index){
@ -1418,8 +1455,10 @@
} }
.xiangxi-box{ .xiangxi-box{
flex: 1; flex: 1;
height: 560rpx;
border: 1px solid #eee; border: 1px solid #eee;
border-radius: 20rpx; border-radius: 20rpx;
overflow: hidden;
} }
.left-box { .left-box {
width: 100%; width: 100%;

5
pages/shop/shopOrderList.vue

@ -165,7 +165,10 @@
} }
}, },
onShow() { onShow() {
if (!uni.getStorageSync('refreshShopOrderList')) return
uni.removeStorageSync('refreshShopOrderList')
this.searchForm.pageNum = 1
this.getList()
}, },
onLoad(option) { onLoad(option) {
if(option.index){ if(option.index){

Loading…
Cancel
Save