123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302 |
- // pages/noticeDetail/detail.js
- const app = getApp();
- let id = 0;
- //创建播放管理器
- let innerAudioContext = null;
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- showModal: false, // 显示modal弹窗
- single: false,
- reason: '',
- details: {},
- detail: [],
- taskContent: {
- title: '任务内容',
- showImg: '/images/icons/play.png',
- playImg: '/images/icons/play.png',
- stopPlayImg: '/images/icons/zanting.png',
- taskRadioType: 1,
- radioUrl: '',
- second: ''
- },
- star: 5,
- starMap: [
- '较差',
- '一般',
- '良好',
- '优秀',
- '完美'
- ],
- checked: '/images/icons/check_star.png',
- unchecked: '/images/icons/shoudaopingjia@2x.png'
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- id = options.id;
- this.showData();
- // this.showTypeData();
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- var that = this;
- app.ajaxReadyCallback = res => {
- var apiname = res.data.apiname;
- if (apiname == 'cancel') {
- wx.showToast({
- title: '取消成功!',
- icon: 'success',
- duration: 1500
- });
- that.setData({
- reason: ''
- });
- that.showData();
- } else if (apiname == 'comment') {
- wx.showToast({
- title: '感谢您的评价!',
- icon: 'success',
- duration: 1500
- });
- that.setData({
- complain: ''
- });
- that.showData();
- } else if (apiname == 'orderConveyType') {
- var arr = [];
- var detail = res.data.data;
- for (var i in detail) {
- var genre = {
- genre: i,
- detail: detail[i]
- }
- arr.push(genre);
- }
- that.setData({
- detail: arr,
- });
- } else {
- var detail = res.data.data;
- if (!detail.images) {
- detail.images = [];
- } else {
- detail.images = detail.images.split(',');
- }
- if (!detail.lastFinishImg) {
- detail.lastFinishImg = [];
- } else {
- detail.lastFinishImg = detail.lastFinishImg.split(',');
- }
- that.setData({
- details: detail,
- });
- wx.setNavigationBarTitle({
- title: '订单查看'
- })
- }
- }
- },
- showData: function () {
- app.ajax({
- url: app.globalData.serverUrl + '/orders/detail',
- type: 'POST',
- data: {
- orderId: id
- }
- });
- },
- showTypeData: function () {
- app.ajax({
- url: app.globalData.serverUrl + '/orderConveyType/list',
- type: 'POST',
- apiname: 'orderConveyType',
- data: {
- orderId: id
- }
- });
- },
- //图片预览
- previewImage: function (e) {
- var current = e.target.dataset.src;
- wx.previewImage({
- current: current, // 当前显示图片的http链接
- urls: this.data.details.images || this.data.details.lastFinishImg, // 需要预览的图片http链接列表
- success: function (e) {
- console.log(e);
- }
- })
- },
- handlePreviewImage: function (e) {
- var current = e.target.dataset.src;
- wx.previewImage({
- current: current, // 当前显示图片的http链接
- urls: this.data.details.lastFinishImg, // 需要预览的图片http链接列表
- success: function (e) {
- console.log(e);
- }
- })
- },
- handleShowModel: function () {
- this.setData({ showModal: true })
- },
- //播放录音
- playRadio: function (event) {
- var taskContent = this.data.taskContent;
- var radioType = taskContent.taskRadioType;
- if (radioType == 1) {
- if (!this.data.details.voices) {
- wx.showToast({
- title: '无音频文件!',
- icon: 'none',
- duration: 1500
- })
- return false;
- }
- var radioUrl = this.data.details.voices.split(',');
- innerAudioContext = null;
- innerAudioContext = wx.createInnerAudioContext();
- innerAudioContext.autoplay = false;
- innerAudioContext.src = radioUrl[0];
- innerAudioContext.play();
- setTimeout(() => {
- innerAudioContext.duration;
- },300)
- innerAudioContext.onTimeUpdate(() => {
- var task = this.data.taskContent;
- task.second = innerAudioContext.duration.toFixed(1)+'"';
- this.setData({
- taskContent: task
- });
- })
- innerAudioContext.onPlay(() => {
- taskContent.taskRadioType = 2;
- taskContent.showImg = taskContent.stopPlayImg;
- this.setData({
- taskContent: taskContent
- })
- });
- innerAudioContext.onError((res) => {
- wx.showToast({
- title: '语音播放失败!',
- icon: 'none',
- duration: 500
- })
- });
- //监听音频自然播放至结束的事件
- innerAudioContext.onEnded((res) => {
- taskContent.taskRadioType = 1;
- taskContent.showImg = taskContent.playImg;
- this.setData({
- taskContent: taskContent
- })
- });
- } else if (radioType == 2) {
- innerAudioContext.stop();
- //监听音频停止事件
- innerAudioContext.onStop((res) => {
- taskContent.taskRadioType = 1;
- taskContent.showImg = taskContent.playImg;
- this.setData({
- taskContent: taskContent
- })
- });
- }
- },
- videotap: function (e) {
- var video = e.target.dataset.video;
- app.gotopage('/pages/video/index', { video: video });
- },
- handleStarChoose(e) {
- let star = parseInt(e.target.dataset.star) || 0;
- this.setData({
- star: star,
- });
- },
- // 点击取消按钮的回调函数
- modalCancel() {
- this.setData({ showModal: false })
- },
- getValue(e) {
- this.setData({
- reason: e.detail.value
- })
- },
- // 取消订单
- handleCancelOrder: function () {
- if (this.data.reason == '') {
- wx.showToast({
- title: '取消原因不能为空!',
- icon: 'none',
- duration: 1500
- })
- setTimeout(function () {
- wx.hideToast()
- }, 2000)
- } else {
- app.ajax({
- url: app.globalData.serverUrl + 'orders/updateOrderModeByUser',
- type: 'POST',
- apiname: 'cancel',
- data: {
- orderId: this.data.details.id,
- reason: this.data.reason,
- }
- });
- }
- },
- // 评价
- handleComplainOrder: function (e) {
- if (e.detail.value.content.length == 0 || e.detail.value.content == '') {
- wx.showToast({
- title: '评价内容不能为空!',
- icon: 'none',
- duration: 1500
- })
- setTimeout(function () {
- wx.hideToast()
- }, 2000)
- } else {
- app.ajax({
- url: app.globalData.serverUrl + '/comment/add',
- type: 'POST',
- apiname: 'comment',
- data: {
- score: this.data.star,
- content: e.detail.value.content,
- type: this.data.details.workTypeMode,
- fromId: this.data.details.id
- }
- });
- }
- },
- handleTransportType(event) {
- var id = event.currentTarget.dataset.id;
- var type = event.currentTarget.dataset.type;
- var num = event.currentTarget.dataset.num;
- wx.navigateTo({
- url: '/pages/order/type/index?id=' + id + '&type=' + type + '&num=' + num
- })
- }
- })
|