123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122 |
- import { match } from "assert";
- var app = getApp();
- var that;
- var setTime;
- Page({
- data: {
- textArea: '',
- point:0,
- review_id:0,
- isAdd:true,
- },
- onLoad(e) {
- that = this;
- dd.setNavigationBar({ title: "调整分数" });
- if (e.id) {
- let isAdd=true;
- let point=e.point;
- console.log(point)
- if(e.point<0){
- isAdd=false;
- point=Math.abs(point)
- }
- that.setData({
- review_id: e.id,
- point:point,
- isAdd:isAdd
- })
- }
- },
- bindKeyInput(e) {
- this.setData({
- point: e.detail.value,
- });
- },
- bindKeyInput2(e) {
- this.setData({
- textArea: e.detail.value,
- });
- },
- //选择奖还是扣(细则)
- bindPickerChange(e) {
- this.setData({
- isAdd:!this.data.isAdd,
- });
- },
- submit() {
- if (!this.data.point) {
- app.globalData.showToast('请输入分数');
- return false;
- }
- if (this.data.point<0||this.data.point=='0'||this.data.point===0) {
- app.globalData.showToast('分数不能小于等于0');
- return false;
- }
- if (!this.data.textArea) {
- app.globalData.showToast('请输调整原因');
- return false;
- }
- // let str = /^1[345789]\d{9}$/
- // if (!str.test(this.data.mobile)) {
- // app.globalData.showToast('手机号码格式不正确')
- // return false
- // }
- let data={
- type:'event_check',
- action:'agree',
- event_id:this.data.review_id,
- comment:this.data.textArea,
- point:this.data.isAdd? this.data.point:this.data.point-(this.data.point*2),
- }
- // console.log(data)
- // return
- that.setData({ disabled: true });
- this.opneWebSocket(data)
- },
- opneWebSocket(data) {
- setTime = setTimeout(() => {
- dd.alert({
- title: '温馨提示',
- content: '网络异常,请检查网络',
- buttonText: '我知道了',
- success: () => {
- clearTimeout(setTime);
- app.globalData.socketApi.closewebsocket();
- that.setData({
- disabled: false,
- isBh: false,
- textArea: '',
- });
- },
- });
- }, 15000)
- app.globalData.socketApi.sendData(data, this.onmessageWS);
- },
- onmessageWS(e) {
- // 因为作用域问题,这个函数不能使用this
- if (e.type == 'event_check') {
- clearTimeout(setTime);
- if(e.code==1){
- app.globalData.showToast("提交成功");
- that.setData({
- disabled: false,
- textArea: '',
- });
- app.globalData.socketApi.closewebsocket();
- setTimeout(() => {
- dd.navigateBack({ delta: 1 })
- }, 1000);
- }else{
- app.globalData.showToast(e.msg)
- app.globalData.socketApi.closewebsocket();
- }
- }
- if (e.type == 'error') {
- clearTimeout(setTime);
- that.setData({
- isShowError: true,
- })
- }
- },
- });
|