123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276 |
- const util = require("../../../utils/util");
- const api = require('../../../api/api.js');
- Page({
- /**
- * 页面的初始数据
- */
- data: {
- orderList: [],
- showType: 0,
- page: 1,
- limit: 10,
- totalPages: 1,
- addressInfo:{},
- myqr_show:false,//我的分享二维码
- myqr_url:null,
- myqr_blur:0,//背景模糊值
- code:'',
- },
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
- let that = this
- try {
- var tab = wx.getStorageSync('tab');
- this.setData({
- showType: tab
- });
- } catch (e) {
-
- }
- },
- getOrderList() {
- wx.showLoading({
- title: '查询中',
- })
- let that = this;
- util.request(api.BookDetailList, {
- showType: that.data.showType,
- page: that.data.page,
- limit: that.data.limit
- }).then(function(res) {
- wx.hideLoading();
- if (res.errno === 0) {
- console.log(res.data);
- that.setData({
- orderList: that.data.orderList.concat(res.data.list),
- totalPages: res.data.pages
- });
- }
- });
- },
- onReachBottom() {
- if (this.data.totalPages > this.data.page) {
- this.setData({
- page: this.data.page + 1
- });
- this.getOrderList();
- } else {
- wx.showToast({
- title: '没有更多订单了',
- icon: 'none',
- duration: 2000
- });
- return false;
- }
- },
- switchTab: function(event) {
- let showType = event.currentTarget.dataset.index;
- this.setData({
- orderList: [],
- showType: showType,
- page: 1,
- limit: 10,
- totalPages: 1
- });
- this.getOrderList();
- },
- makeCall(e){
- let mobile = e.currentTarget.dataset.mobile;
- wx.makePhoneCall({
- phoneNumber: mobile,
- })
- },
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
- },
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
- this.setData({
- orderList: [],
- showType: this.data.showType,
- page: 1,
- limit: 10,
- totalPages: 1
- });
- this.getOrderList();
- },
- goProvideBook(e){//完成服务
- let that=this;
- let id=e.currentTarget.dataset.id;
- wx.showModal({
- title: '完成服务',
- confirmColor: '#b4282d',
- content: '确定完成此服务?完成后,无法修改',
- success: function (res) {
- if (!res.confirm) {
- return;
- }
- util.request(api.BookDetailProvice,{id:id}).then(res=>{
- if(res.errno==0){
- wx.showToast({
- title: '服务完成',
- icon: 'success',
- });
- var list=that.data.orderList;
- list.forEach(item=>{
- item.details.forEach(dt=>{
- if(dt.id==id){
- dt.status="服务已提供";
- dt.statusId=3;
- }
- })
- })
- that.setData({
- orderList:list
- })
- }
- })
- }
- })
- },
- openMap(e){//打开地图
- let address=e.currentTarget.dataset.address;
- let lng=e.currentTarget.dataset.lng;
- let lat=e.currentTarget.dataset.lat;
- // console.info(lng)
- // console.info(lat)
- // console.info(address)
- wx.openLocation({
- latitude: lat,
- longitude: lng,
- name: address,
- address:address,
- scale: 28
- })
- },
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
- },
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
- },
-
- shareGoods(e){
- let that=this;
- wx.showLoading({title: '生成中',});
- util.request(api.GoodsShare, {
- goodsId:e.currentTarget.dataset.id
- }).then(function(res) {
- console.info(res)
- wx.hideLoading();
- if(res.errno==0){
- that.setData({
- myqr_url:res.data.imgUrl,
- myqr_show:true,
- myqr_blur:5
- });
- } else if(res.errno==501){
- // wx.navigateTo({
- // url: "/pages/index/index"
- // });
- } else {
- wx.showToast({
- title: res.errmsg,
- duration:5000
- })
- }
- });
-
- },
- qrtouchstart:function(){
- this.setData({
- myqr_blur:0,
- myqr_show:false
- });
- },
- saveShare: function() {
- let that = this;
- wx.showLoading({
- title: '图片保存中',
- });
- console.log(that.data);
- wx.downloadFile({
- url: that.data.myqr_url,
- success: function(res) {
- console.log(res)
- wx.saveImageToPhotosAlbum({
- filePath: res.tempFilePath,
- success: function(res) {
- wx.hideLoading();
- wx.showModal({
- title: '存图成功',
- content: '图片成功保存到相册了,可以分享到朋友圈了',
- showCancel: false,
- confirmText: '好的',
- confirmColor: '#a78845',
- success: function(res) {
- if (res.confirm) {
- console.log('用户点击确定');
- that.setData({
- myqr_show:false,
- myqr_blur:0
- });
- }
- }
- })
- },
- fail: function(res) {
- wx.hideLoading();
- wx.showModal({
- title: '警告',
- content: '未授权无法保存',
- showCancel: false
- })
- that.setData({
- myqr_show:false,
- myqr_blur:0
- });
- }
- })
- },
- fail: function(res) {
- wx.hideLoading();
- console.log(res);
- }
- })
- },
- })
|