| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208 |
- // pages/orderDetail/orderDetail.js
- const app = getApp()
- import http from "../../utils/http"
- import util from "../../utils/util"
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- order_id: '',
- info: '',
- show: false,
- images: [],
- safeBottom: `30px`,
- settle: ''
- },
-
- copy(event){
- wx.setClipboardData({
- data: event.currentTarget.dataset.content,
- success (res) {
- util.toast('已复制')
- }
- })
- },
- navigation(){
- wx.openLocation({
- latitude : Number(this.data.info.orderAddress.lat),
- longitude : Number(this.data.info.orderAddress.lng),
- name: this.data.info.orderAddress.area,
- scale: 18
- })
- },
- call(){
- wx.makePhoneCall({
- phoneNumber: this.data.info.orderAddress.mobile
- })
- },
- onClose(){
- this.setData({
- show: false
- })
- },
- showUpload(){
- this.setData({
- show: true
- })
- },
- delImages(e){
- let index = e.currentTarget.dataset.index
- this.data.images.splice(index,1)
- this.setData({
- images: this.data.images
- })
- },
- chooseImages(e) {
- let index = e.currentTarget.dataset.index
- http.chooseImg(['camera'], true).then(res => {
- let arr = this.data.images;
- if(index !== undefined){
- arr.splice(index,1,res.data.url)
- }else {
- arr.push(res.data.url)
- }
- this.setData({
- images: arr
- })
- })
- },
- getInfo(){
- http.post('order/orderInfo', {
- id: this.data.order_id
- }).then(res => {
- this.setData({
- info: res.data
- })
- if(res.data.is_settle > 0 ){
- this.getSettle()
- }
-
- })
- },
- getSettle(){
- http.post('order/priceInfo', {
- id: this.data.order_id
- }).then(res => {
- this.setData({
- settle: res.data
- })
- })
- },
- accept(){
- http.post('order/skillaccept',{
- id: this.data.order_id
- }, true, false).then(res => {
- util.toast('抢单成功')
- this.getInfo()
- }).catch(e => {
- let data = e.data
- if(data.code === 2){
- util.toast(data.msg)
- }else if(data.code === 0){
- util.toast(data.data)
- }
- })
- },
- go(){
- http.post('order/skillgo', {
- id: this.data.order_id
- }).then(res => {
- this.getInfo()
- })
- },
- arrive(){
- if(this.data.images.length === 0) return util.toast('请上传图片')
- http.post('order/skillreach', {
- id: this.data.order_id,
- reach_images: this.data.images.join(',')
- }).then(res => {
- this.setData({
- images: [],
- show: false
- })
- this.getInfo()
- })
- },
- finish(){
- if(this.data.images.length === 0) return util.toast('请上传图片')
- http.post('order/skillfinish', {
- id: this.data.order_id,
- finish_images: this.data.images.join(',')
- }).then(res => {
- this.setData({
- images: [],
- show: false
- })
- this.getInfo()
- })
- },
- start(){
- http.post('order/skillstart', {
- id: this.data.order_id
- }).then(res => {
- this.getInfo()
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad(options) {
- const high = app.globalData.safeBottom
- this.setData({
- order_id: options.id,
- safeBottom: `${high}px`
- })
-
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow() {
- this.getInfo()
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage() {
- }
- })
|