import { get } from "../../utils/http" // pages/clientInfo/clientInfo.js Page({ /** * 页面的初始数据 */ data: { urls: [ "https://img1.baidu.com/it/u=202543353,3627416815&fm=26&fmt=auto", "https://img0.baidu.com/it/u=745609344,230882238&fm=26&fmt=auto", "https://img0.baidu.com/it/u=286636366,3227707112&fm=26&fmt=auto", "https://img1.baidu.com/it/u=2450865760,444795162&fm=26&fmt=auto", "https://img0.baidu.com/it/u=4226275504,4103997964&fm=26&fmt=auto", "https://img0.baidu.com/it/u=2247422843,411257408&fm=26&fmt=auto", "https://img0.baidu.com/it/u=3098615520,360170704&fm=26&fmt=auto", "https://img1.baidu.com/it/u=510862345,2249984174&fm=26&fmt=auto", "https://img2.baidu.com/it/u=2222750380,2392750381&fm=26&fmt=auto", ], sex: { 0: '保密', 1: '男', 2: '女' }, calendar: {}, calendarConfig: { takeoverTap: true, }, userId: '', orderId: '', list: [], total: 0, page: 1, tags: ['美丽貌美','短短胳膊粗粗的腿','闭月羞花','人美声甜白富美'] }, /** * 生命周期函数--监听页面加载 */ onLoad: function (options) { console.log(options) if(options.userId) { this.setData({ userId: options.userId, orderId: options.orderId, },() => { // this.getUserInfo() this.getfeedbackList() }) } }, /** * 生命周期函数--监听页面初次渲染完成 */ onReady: function () { }, /** * 生命周期函数--监听页面显示 */ onShow: function () { this.getUserInfo() }, /** * 生命周期函数--监听页面隐藏 */ onHide: function () { }, /** * 生命周期函数--监听页面卸载 */ onUnload: function () { }, /** * 页面相关事件处理函数--监听用户下拉动作 */ onPullDownRefresh: function () { }, /** * 页面上拉触底事件的处理函数 */ onReachBottom: function () { if(this.data.page * 10 < this.data.total) { this.getfeedbackList(++this.data.page) } }, /** * 用户点击右上角分享 */ onShareAppMessage: function () { }, afterCalendarRender(e) { this.data.calendar = this.selectComponent('#calendar').calendar console.log(this.data.calendar.getCurrentYM()) this.getOrderCalendar() console.log('afterCalendarRender -> calendar', this.data.calendar) const toSet = [ { year: 2021, month: 11, date: 15 }, { year: 2019, month: 3, date: 18 } ] this.data.calendar.setSelectedDates(toSet) }, /** * 当日历滑动时触发 */ onSwipe(e) { console.log('onSwipe', e.detail) this.getOrderCalendar() }, /** * 日期点击事件(此事件会完全接管点击事件),需自定义配置 takeoverTap 值为真才能生效 * currentSelect 当前点击的日期 */ takeoverTap(e) { let { userId } = this.data; if(e.detail.choosed) { wx.navigateTo({ url: `/pages/historyOrder/historyOrder?user_id=${userId}&detail=${JSON.stringify(e.detail)}`, }) console.log('takeoverTap', e.detail) // => { year: 2019, month: 12, date: 3, ...} } }, /** * 图片预览 */ previewMedia(e) { let { idx,index } = e.currentTarget.dataset; let arr = this.data.list[idx].media_list let current = index wx.previewMedia({ sources: arr, current }) }, /** * 获取客户信息 * api/user/info */ getUserInfo(user_id) { let { userId } = this.data; get('api/user/info',{ user_id: userId },(res) => { this.setData({ userInfo: res.data }) console.log(res) }) }, /** * 获取订单反馈记录 * api/feedback/list/user */ getfeedbackList(_page) { let { page,list,userId } = this.data; get('api/feedback/list/user',{ user_id: userId, page: _page || page, limit: 10 },(res) => { console.log(res) res.data.list.forEach((item,index) => { item.media_list = JSON.parse(item.media_list) }) list.push(...res.data.list) this.setData({ list,total: res.data.total, }) }) }, /** * 获取日历 * api/order/calendar */ getOrderCalendar() { let calendar = this.data.calendar; let month = calendar.getCurrentYM().month; console.log(this.data.calendar.getCurrentYM()) get('api/order/calendar',{ user_id: this.data.userId, month: `${calendar.getCurrentYM().year}-${month < 10 ? '0' + month : month }` },(res) => { let dates = [] calendar.cancelSelectedDates(dates) res.data.forEach((item,index) => { if(item.num > 0) { dates.push({ year: calendar.getCurrentYM().year, month: calendar.getCurrentYM().month, date: item.day }) } console.log(item) }) calendar.setSelectedDates(dates) console.log(dates) console.log(res) }) } })