| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201 |
- // pages/detail/detail.js
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- cover: true,
- bright_points: '',
- message: {
- '0': '确认订单',
- '1': '订单关闭',
- '2': '已确认',
- '3': '订单中止',
- '4': '订单完成'
- },
- status: 0
- },
- // 报名
- apply() {
- this.setData({
- cover: true,
- })
- wx.kx_request({
- url: wx.kx_api.hwRequirement.enrollmentRequire,
- model: true,
- type: 'post',
- data: {
- requirement_id: this.data.id,
- bright_points: this.data.bright_points,
- enroll_from: 0
- },
- success: res => {
- wx.showToast({
- title: '报名成功',
- })
- },
- fail: res => {
- if (res.errcode) {
- wx.showModal({
- title: '报名失败',
- content: res.errmsg,
- showCancel: false,
- confirmColor: '#31364C'
- })
- }
- }
- })
- },
- // 亮点输入
- input(e) {
- this.setData({
- bright_points: e.detail.value
- })
- },
- // 打开地图
- openMap(e) {
- const name = e.currentTarget.dataset.name;
- const address = e.currentTarget.dataset.address;
- // wx.openLocation({
- // latitude: 31.544325,
- // longitude: 120.356595,
- // name,
- // address
- // })
- },
- // 查看合同
- buttonCheck() {
- wx.downloadFile({
- url: this.data.hwOrderAPI.workContract,
- success: (res) => {
- wx.openDocument({
- filePath: res.tempFilePath,
- })
- }
- })
- },
- // 确认订单
- buttonSubmit() {
- wx.kx_request({
- url: wx.kx_api.hwOrder.confirmOrder,
- type: 'post',
- data: {
- orderId: this.data.hwOrderAPI.id
- },
- success: res => {
- if (res.errcode === 0) {
- wx.showToast({
- title: '订单已确认',
- success: res => {
- const hwOrderAPI = this.data.hwOrderAPI;
- hwOrderAPI.status = 2;
- this.setData({
- hwOrderAPI
- })
- }
- })
- }
- }
- })
- },
- /* 控制cover层的显示与隐藏 */
- cover() {
- const cover = !this.data.cover;
- this.setData({
- cover
- })
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function(options) {
- if (options.id && options.status) {
- if (options.status === '3') {
- wx.kx_request({
- url: wx.kx_api.hwOrder.getOrderDetail,
- data: {
- orderId: options.id
- },
- success: res => {
- if (res.errcode === 0) {
- this.setData({
- ...res.data.hwRequirementAPI,
- hwOrderAPI: res.data.hwOrderAPI
- })
- }
- }
- })
- }
- if (options.status === '1') {
- wx.kx_request({
- url: wx.kx_api.hwRequirement.getRequirementDetail,
- data: {
- hwRequirementId: options.id
- },
- success: res => {
- if (res.errcode === 0) {
- this.setData({
- ...res.data.hwRequirementAPI
- })
- }
- }
- })
- }
- }
- if (options.status) {
- this.setData({
- status: options.status - 0
- })
- }
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function() {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function() {
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function() {
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function() {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function() {
- },
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function() {
- },
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function() {
- }
- })
|