finish update

This commit is contained in:
英树 2020-06-11 15:06:19 +08:00
parent cee8715f8e
commit c582bc1ad6
9 changed files with 320 additions and 263 deletions

View File

@ -129,7 +129,7 @@ var update = async (event) => {
isfree: event.isfree,
photos: event.photos,
time: (new Date(new Date().getTime() + 1000 * 60 * 60 * 8)).Format("yyyy-MM-dd hh:mm:ss"), //+8时差
formId: event.formId2,
needSend: event.needSend,
}
}).then(res => {
return {
@ -144,31 +144,34 @@ var update = async (event) => {
}
})
// 直接进行返回,不向用户发送信息
return res
//如果添加失败就直接返回
if(res.errCode === 106) return res;
// if(res.errCode === 106) return res;
//发信息(预留错误码107发送失败)
var sendRes = await cloud.callFunction({
name: 'sM_sendMsg',
data: {
stats: 1,
sendId: event.userInfos._openid,
sendName: event.userInfos.userName,
title: event.title,
formId1: event.formId1,
examineId: res.errMsg,
}
}).then(res => {
return res.result
}).catch(err => {
return {
errCode: 107,
errMsg: '用户点击发布函数调用错误',
err: err,
}
})
// var sendRes = await cloud.callFunction({
// name: 'sM_sendMsg',
// data: {
// stats: 1,
// sendId: event.userInfos._openid,
// sendName: event.userInfos.userName,
// title: event.title,
// formId1: event.formId1,
// examineId: res.errMsg,
// }
// }).then(res => {
// return res.result
// }).catch(err => {
// return {
// errCode: 107,
// errMsg: '用户点击发布函数调用错误',
// err: err,
// }
// })
return sendRes;
// return sendRes;
}
//审核通过
@ -185,6 +188,7 @@ var pass = async (event) => {
var reRes = await rewriteUserInfo(addRes.errMsg, event);
if (reRes.errCode !== 200) return reRes;
if (event.needSend) {
//发信息(预留错误码107)
var sendRes = await cloud.callFunction({
name: 'sM_sendMsg',
@ -194,7 +198,6 @@ var pass = async (event) => {
sendName: event.userInfos.userName,
result: "审核通过",
remarks: event.remarks + "\n注点击下方即可进入小程序",
formId: event.formId,
}
}).then(res => {
return res.result;
@ -205,16 +208,18 @@ var pass = async (event) => {
err: err,
}
})
return sendRes;
}
return reRes
}
//审核失败
var fail = async (event) => {
//删除审核表旧纪录
var delRes = await deleteOldOne(event.oldId);
if (delRes.errCode !== 200) return delRes;
if (event.needSend) {
//发信息(预留错误码107)
var sendRes = await cloud.callFunction({
name: 'sM_sendMsg',
@ -224,7 +229,6 @@ var fail = async(event) => {
sendName: event.userInfos.userName,
result: "审核失败",
remarks: event.remarks + "\n注您的商品信息已被删除请重新发布。",
formId: event.formId,
}
}).then(res => {
return res.result;
@ -238,6 +242,8 @@ var fail = async(event) => {
return sendRes;
}
return delRes
}
// 云函数入口函数
exports.main = async (event, context) => {
@ -298,6 +304,19 @@ exports.main = async (event, context) => {
注意需要获取oldId给发消息用不过得等前端写完页面之后
作者RainSun
时间2019/04/29
更新
参数
stats = 1 用户点击发布时
userInfos 数据库里边的用户完整信息
title商品名
details商品详细信息
adds地址
tag标签
price价格
isfree是否免费
photos照片地址数组
needSend: 是否允许发送成功通知
时间2020/06/10
*/
/*
日志
@ -305,6 +324,10 @@ exports.main = async (event, context) => {
20190430
今天完成错误信息的返回详情见下方错误报告
代码格式整理完成
20200610
因为小程序比赛回来改代码因为模板消息改成了订阅消息
所以取消上传成功的订阅消息只保留审核完成的订阅消息
如果用户不同意还可以不发送
*/
/*

View File

@ -69,29 +69,24 @@ var startExamine = async (event) => {
//审核结果
var passExamine = async (event) => {
//给被审核人发送消息说审核结果
var res = await cloud.openapi.templateMessage.send({
var res = await cloud.openapi.subscribeMessage.send({
touser: event.sendId,
page: 'components/welcome/welcome',
data: {
keyword1: {
//申请人
value: event.sendName
// 审核类型
thing18: {
value: '上传物品'
},
keyword2: {
//申请内容
value: "发布商品"
},
keyword3: {
// 审核结果
thing19: {
value: event.result
},
keyword4: {
// 备注
thing17: {
value: event.remarks
}
},
templateId: 'ZSTBhVkZwfX2ZgDfiAL8uBMeuJ_zFJfJFch4zqzpBZ8',
formId: event.formId,
},
templateId: 'PPngF-ljr1S6yixiorFJ4bj8t8mP5odUhHEnu_08Smw',
}).then(res => {
return {
errCode: 200,
@ -108,9 +103,10 @@ var passExamine = async (event) => {
}
exports.main = async (event, context) => {
if(event.stats == 1) var res = await startExamine(event);
else if(event.stats == 2) var res = await passExamine(event);
return res;
// if(event.stats == 1) var res = await startExamine(event);
// else if(event.stats == 2) var res = await passExamine(event);
// return res;
return await passExamine(event)
}
/*
@ -133,6 +129,12 @@ exports.main = async (event, context) => {
注意在前端写完界面之后要在这里加入跳转界面给管理员用
作者RainSun
时间2019/05/01
更新
参数
sendId: 收件人openid
result 结果 审核通过 或者 审核失败
remarks 备注 随便填
时间2020/06/10
*/
/*
错误报告

View File

@ -1,7 +1,7 @@
// components/createProj/createProj.js
//去除字符串两边留白
String.prototype.trim = function () {
  return this.replace(/(^\s*)|(\s*$)/g, "");
return this.replace(/(^\s*)|(\s*$)/g, "");
}
var App = getApp();
Page({
@ -17,8 +17,6 @@ Page({
price: '',
isfree: false,
imgList: [],
formId1:null,
formId2:null,
customBar: null,
showSubmit: false,
showError: false,
@ -217,15 +215,31 @@ Page({
}
console.log(this.data)
},
submit (e) {
// 申请发送模板消息
requestSubscribeMessage() {
this.hideModal()
wx.requestSubscribeMessage({
tmplIds: ['PPngF-ljr1S6yixiorFJ4bj8t8mP5odUhHEnu_08Smw'],
}).then(res => {
console.log(res)
if(res['PPngF-ljr1S6yixiorFJ4bj8t8mP5odUhHEnu_08Smw'] == 'reject') {
// 用户点击不同意
this.submit(false)
} else {
// 用户同意
this.submit()
}
}).catch(err => {
console.log(err)
})
},
submit(needSend = true) {
var userInfo = wx.getStorageSync('userInfoDetail');
wx.showLoading({
title: '上传中',
mask: true
})
this.data.formId2 = e.detail.formId;
if (this.data.photos.length !== this.data.imgList.length) {
wx.showToast({
title: '请等待图片上传完成',
@ -245,8 +259,7 @@ Page({
price: d.price,
isfree: d.isfree,
photos: d.photos,
formId1:d.formId1,
formId2:d.formId2,
needSend: needSend
}
console.log(data);
wx.cloud.callFunction({
@ -274,11 +287,12 @@ Page({
tag: null,
isfree: false,
imgList: [],
formId1:null,
formId2:null,
showSubmit: false,
showError: false,
photos: [],
title: '',
details: '',
price: '',
})
}
}).catch(err => {
@ -292,8 +306,9 @@ Page({
})
},
// 点击我填完了校验内容
judge(e) {
this.data.formId1 = e.detail.formId
let d = this.data
if (d.title && d.details && d.adds && d.tag && d.price !== null) {
this.setData({
@ -306,7 +321,7 @@ Page({
}
},
//判断是否注册
//点击确认上传,判断是否注册
judgeHasSign(e) {
var userInfo = wx.getStorageSync('userInfoDetail');
if (!userInfo.isSign) {
@ -324,7 +339,8 @@ Page({
}
})
} else {
this.submit(e);
// 校验通过,申请发送完成的信息
this.requestSubscribeMessage(e);
}
},

View File

@ -65,7 +65,7 @@
</view>
<view class="cu-form-group">
<view class="grid col-4 grid-square flex-sub">
<view class="padding-xs bg-img" style="background-image:url({{imgList[index]}})" wx:for="{{imgList}}" wx:key="{{index}}" bindtap="ViewImage" data-url="{{imgList[index]}}">
<view class="padding-xs bg-img" style="background-image:url({{imgList[index]}})" wx:for="{{imgList}}" wx:key="index" bindtap="ViewImage" data-url="{{imgList[index]}}">
<view class="cu-tag bg-red" catchtap="DelImg" data-index="{{index}}">
<text class="icon-close" style="color:#fff;"></text>
</view>
@ -80,7 +80,7 @@
</form>
</view>
<form bindsubmit='judge' report-submit='true'>         
<form bindsubmit='judge'>         
<button class='submit' form-type='submit'>我填完了</button>       
</form>
@ -96,7 +96,7 @@
下一步将进入审核,是否确认提交
</view>
<view class="cu-bar bg-white justify-end">
<form class="action" report-submit='true' bindsubmit='judgeHasSign'>
<form class="action" bindsubmit='judgeHasSign'>
<button class="cu-btn cancel-button" bindtap="hideModal" >取消</button>
<button class="cu-btn confirm-button margin-left" form-type="submit">确定</button>
</form>
@ -116,7 +116,7 @@
除了图片每一项都是必填项,请检查。
</view>
<view class="cu-bar bg-white justify-end">
<form class="action" report-submit="{{true}}">
<form class="action" >
<button class="cu-btn confirm-button margin-left" bindtap="hideModal" form-type="submit">确定</button>
</form>
</view>

View File

@ -128,6 +128,7 @@ Page({
oldId: proj._id,
remarks: this.data.inputValue,
formId:proj.formId,
needSend: proj.needSend
}
} else {
var data = {
@ -135,7 +136,8 @@ Page({
userInfos: proj.userInfo,
oldId:proj._id,
remarks: this.data.inputValue,
formId: proj.formId
formId: proj.formId,
needSend: proj.needSend
}
}
wx.cloud.callFunction({

View File

@ -49,7 +49,7 @@
<textarea wx:if="{{isShowModal}}" class="input-box radius" show-confirm-bar="false" bindinput="inputChange" value="{{inputValue}}" focus="{{true}}"></textarea>
</view>
<view class="cu-bar bg-white justify-end">
<form bindsubmit="submit" report-submit='{{true}}' class="action">
<form bindsubmit="submit" class="action">
<button class="cu-btn line-green text-green" bindtap="hideModal">取消</button>
<button form-type="submit" class="cu-btn bg-green margin-left" bindtap="hideModal">提交</button>
</form>

View File

@ -13,7 +13,7 @@
<!-- swiper -->
<swiper class="card-swiper square-dot" indicator-dots="true" circular="true" autoplay="true" interval="5000" duration="500" bindchange="cardSwiper" indicator-color="#aaa" indicator-active-color="#fff">
<swiper-item wx:for="{{swiperList}}" wx:key class="{{cardCur==index?'cur':''}}">
<swiper-item wx:for="{{swiperList}}" wx:key="index" class="{{cardCur==index?'cur':''}}">
<view class="swiper-item">
<image src="{{item.url}}" mode="aspectFill"></image>
</view>
@ -23,7 +23,7 @@
<!-- 标签列表 -->
<view class="tag-box">
<view class="item-box" bindtap="goToTagSearch" data-tagtype="图书">
<view class="item-box" bindtap="requestSubscribeMessage" data-tagtype="图书">
<image src="cloud://cloud-83621f.636c-cloud-83621f/cherryStore/book.png" />
<view class="text">图书</view>
</view>
@ -74,7 +74,7 @@
<!-- 商品列表 -->
<view class="product-list" >
<view class="product-item" wx:for="{{list}}" wx:key wx:if="{{!item.isSall}}" data-productId="{{item._id}}" bindtap="jumpToDetail">
<view class="product-item" wx:for="{{list}}" wx:key="index" wx:if="{{!item.isSall}}" data-productId="{{item._id}}" bindtap="jumpToDetail">
<view class="user-box">
<image src="{{item.userAvatarUrl}}" />
<view class="user-info">

View File

@ -101,6 +101,7 @@ Page({
} else {
//已经登陆过了
var userInfo = res.data[0];
console.log(userInfo)
wx.setStorageSync('userInfoDetail', userInfo);
if(userInfo.isSign) wx.setStorageSync('isSign', true);
else wx.setStorageSync('isSign',false);

View File

@ -7,11 +7,24 @@
"postcss": true,
"minified": true,
"newFeature": true,
"checkSiteMap": false
"coverView": true,
"autoAudits": false,
"showShadowRootInWxmlPanel": true,
"scopeDataCheck": false,
"checkInvalidKey": true,
"checkSiteMap": false,
"uploadWithSourceMap": true,
"babelSetting": {
"ignore": [],
"disablePlugins": [],
"outputPath": ""
},
"useCompilerModule": false,
"userConfirmedUseCompilerModuleSwitch": false
},
"appid": "wx0df150c438e4c8f0",
"projectname": "cherry%20Store",
"libVersion": "2.7.1",
"libVersion": "2.11.1",
"simulatorType": "wechat",
"simulatorPluginLibVersion": {},
"cloudfunctionTemplateRoot": "cloudfunctionTemplate",