123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244 |
- const app = getApp()
- const util = require("../../../utils/util");
- const api = require('../../../api/api.js');
- const user = require('../../../utils/user.js');
- const map = require('../../../utils/map');
- import moment from 'moment'
- Page({
- data: {
- detailId: '',
- qrCodeUrl: '',
- status: '',
- latlng: '',
- finishImg: '',
- channelId: ''
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- if (options.serviceId) {
- this.setData({
- serviceId: options.serviceId,
- detailServantId: options.detailServantId,
- channelId: options.channelId
- });
- // this.getQrCode()
- }
- let that = this;
- wx.getLocation({
- type: 'wgs84',
- success(res) {
- console.log(res);
- that.setData({
- latlng: res.longitude + ',' + res.latitude
- })
- // const latitude = res.latitude
- // const longitude = res.longitude
- },
- fail(res) {
- wx.showToast({
- title: "请点击右上角打开位置授权",
- icon: 'none'
- })
- }
- })
- },
- chooseImg(e) {
- var that = this;
- wx.chooseMedia({
- count: 1,
- mediaType: ['image'],
- sourceType: ['camera'],
- camera: 'back',
- sizeType: ['original', 'compressed'],
- success: function (res) {
- let file = res.tempFiles[0].tempFilePath
- // that.upload(file);
- wx.compressImage({
- src: file, // 图片路径
- quality: 75, // 压缩质量
- success(res) {
- console.log(res);
- that.upload(res.tempFilePath);
- },
- fail: (err) => {
- console.error(err);
- wx.showToast({
- title: '微信压缩图片失败:' + err,
- icon: 'none'
- })
- }
- })
- }
- })
- },
- upload: function (path) {
- var that = this;
- const uploadTask = wx.uploadFile({
- url: api.StorageUpload(),
- filePath: path, //res.tempFilePaths[0],
- name: 'file',
- success: function (res) {
- var _res = JSON.parse(res.data);
- if (_res.errno === 0) {
- var url = _res.data.fileUrl
- that.setData({
- finishImg: url,
- });
- }
- }
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.getQrCode()
- },
- goBack() {
- wx.navigateBack();
- },
- getQrCode() {
- wx.showLoading({
- title: '加载中...',
- });
- util.request(api.serviceOrderAcceptanceCheck, {
- serviceId: this.data.serviceId
- }, 'GET').then(res => {
- wx.hideLoading();
- if (res.errno === 0) {
- this.setData({
- qrCodeUrl: res.data.qrCodeUrl,
- status: res.data.status
- });
- }
- }).catch(err => {
- wx.hideLoading();
- });
- },
- sendFinish() {
- this.finishOrder();
- // this.sendSms();
- },
- checkFinish() {
- this.finishOrder(true);
- },
- finishOrder(flag) {
- console.log(flag);
- let that = this;
- if (this.data.channelId == 112) { //花王渠道
- if (this.data.finishImg == '') {
- wx.showToast({
- title: '花王工单,需上传工具包整理照片',
- icon: 'none'
- });
- return;
- }
- }
- util.request(api.finishServiceOrder, {
- serviceId: that.data.serviceId,
- detailServantId: that.data.detailServantId,
- latlng: that.data.latlng,
- address: '',
- finishImg: that.data.finishImg
- }, 'GET').then(res2 => {
- console.log(res2);
- wx.hideLoading();
- if (res2.errno == 0) {
- wx.showToast({
- title: '操作成功',
- icon: 'none',
- });
- if (flag) {
- wx.navigateTo({
- url: '/pages/problem/list/list?bookTradeNo=' + that.data.serviceId,
- })
- } else {
- this.sendSms();
- }
- } else {
- wx.showToast({
- title: res2.errmsg + ',' + res2.data,
- icon: 'none',
- });
- }
- }).catch(err => {
- wx.hideLoading();
- });
- // map.getLocation().then((res)=>{
- // console.log(res);
- // }).catch((res)=>{
- // console.log('fail' + JSON.stringify(res))
- // });
- },
- sendSms() {
- // wx.showLoading({
- // title: '加载中...',
- // });
- util.request(api.smsEvaluate, {
- serviceId: this.data.serviceId
- }, 'GET').then(res => {
- // wx.hideLoading();
- if (res.errno === 0) {
- }
- }).catch(err => {
- wx.hideLoading();
- });
- },
- onHide: function () {
- },
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
- })
|