clientInfo.js 5.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227
  1. import { get } from "../../utils/http"
  2. // pages/clientInfo/clientInfo.js
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. urls: [
  9. "https://img1.baidu.com/it/u=202543353,3627416815&fm=26&fmt=auto",
  10. "https://img0.baidu.com/it/u=745609344,230882238&fm=26&fmt=auto",
  11. "https://img0.baidu.com/it/u=286636366,3227707112&fm=26&fmt=auto",
  12. "https://img1.baidu.com/it/u=2450865760,444795162&fm=26&fmt=auto",
  13. "https://img0.baidu.com/it/u=4226275504,4103997964&fm=26&fmt=auto",
  14. "https://img0.baidu.com/it/u=2247422843,411257408&fm=26&fmt=auto",
  15. "https://img0.baidu.com/it/u=3098615520,360170704&fm=26&fmt=auto",
  16. "https://img1.baidu.com/it/u=510862345,2249984174&fm=26&fmt=auto",
  17. "https://img2.baidu.com/it/u=2222750380,2392750381&fm=26&fmt=auto",
  18. ],
  19. sex: {
  20. 0: '保密',
  21. 1: '男',
  22. 2: '女'
  23. },
  24. calendar: {},
  25. calendarConfig: {
  26. takeoverTap: true,
  27. },
  28. userId: '',
  29. orderId: '',
  30. list: [],
  31. total: 0,
  32. page: 1,
  33. tags: ['美丽貌美','短短胳膊粗粗的腿','闭月羞花','人美声甜白富美']
  34. },
  35. /**
  36. * 生命周期函数--监听页面加载
  37. */
  38. onLoad: function (options) {
  39. console.log(options)
  40. if(options.userId) {
  41. this.setData({
  42. userId: options.userId,
  43. orderId: options.orderId,
  44. },() => {
  45. // this.getUserInfo()
  46. this.getfeedbackList()
  47. })
  48. }
  49. },
  50. /**
  51. * 生命周期函数--监听页面初次渲染完成
  52. */
  53. onReady: function () {
  54. },
  55. /**
  56. * 生命周期函数--监听页面显示
  57. */
  58. onShow: function () {
  59. this.getUserInfo()
  60. },
  61. /**
  62. * 生命周期函数--监听页面隐藏
  63. */
  64. onHide: function () {
  65. },
  66. /**
  67. * 生命周期函数--监听页面卸载
  68. */
  69. onUnload: function () {
  70. },
  71. /**
  72. * 页面相关事件处理函数--监听用户下拉动作
  73. */
  74. onPullDownRefresh: function () {
  75. },
  76. /**
  77. * 页面上拉触底事件的处理函数
  78. */
  79. onReachBottom: function () {
  80. if(this.data.page * 10 < this.data.total) {
  81. this.getfeedbackList(++this.data.page)
  82. }
  83. },
  84. /**
  85. * 用户点击右上角分享
  86. */
  87. onShareAppMessage: function () {
  88. },
  89. afterCalendarRender(e) {
  90. this.data.calendar = this.selectComponent('#calendar').calendar
  91. console.log(this.data.calendar.getCurrentYM())
  92. this.getOrderCalendar()
  93. console.log('afterCalendarRender -> calendar', this.data.calendar)
  94. const toSet = [
  95. {
  96. year: 2021,
  97. month: 11,
  98. date: 15
  99. },
  100. {
  101. year: 2019,
  102. month: 3,
  103. date: 18
  104. }
  105. ]
  106. this.data.calendar.setSelectedDates(toSet)
  107. },
  108. /**
  109. * 当日历滑动时触发
  110. */
  111. onSwipe(e) {
  112. console.log('onSwipe', e.detail)
  113. this.getOrderCalendar()
  114. },
  115. /**
  116. * 日期点击事件(此事件会完全接管点击事件),需自定义配置 takeoverTap 值为真才能生效
  117. * currentSelect 当前点击的日期
  118. */
  119. takeoverTap(e) {
  120. let { userId } = this.data;
  121. if(e.detail.choosed) {
  122. wx.navigateTo({
  123. url: `/pages/historyOrder/historyOrder?user_id=${userId}&detail=${JSON.stringify(e.detail)}`,
  124. })
  125. console.log('takeoverTap', e.detail) // => { year: 2019, month: 12, date: 3, ...}
  126. }
  127. },
  128. /**
  129. * 图片预览
  130. */
  131. previewMedia(e) {
  132. let { idx,index } = e.currentTarget.dataset;
  133. let arr = this.data.list[idx].media_list
  134. let current = index
  135. wx.previewMedia({
  136. sources: arr,
  137. current
  138. })
  139. },
  140. /**
  141. * 获取客户信息
  142. * api/user/info
  143. */
  144. getUserInfo(user_id) {
  145. let { userId } = this.data;
  146. get('api/user/info',{
  147. user_id: userId
  148. },(res) => {
  149. this.setData({
  150. userInfo: res.data
  151. })
  152. console.log(res)
  153. })
  154. },
  155. /**
  156. * 获取订单反馈记录
  157. * api/feedback/list/user
  158. */
  159. getfeedbackList(_page) {
  160. let { page,list,userId } = this.data;
  161. get('api/feedback/list/user',{
  162. user_id: userId,
  163. page: _page || page,
  164. limit: 10
  165. },(res) => {
  166. console.log(res)
  167. res.data.list.forEach((item,index) => {
  168. item.media_list = JSON.parse(item.media_list)
  169. })
  170. list.push(...res.data.list)
  171. this.setData({ list,total: res.data.total, })
  172. })
  173. },
  174. /**
  175. * 获取日历
  176. * api/order/calendar
  177. */
  178. getOrderCalendar() {
  179. let calendar = this.data.calendar;
  180. let month = calendar.getCurrentYM().month;
  181. console.log(this.data.calendar.getCurrentYM())
  182. get('api/order/calendar',{
  183. user_id: this.data.userId,
  184. month: `${calendar.getCurrentYM().year}-${month < 10 ? '0' + month : month }`
  185. },(res) => {
  186. let dates = []
  187. calendar.cancelSelectedDates(dates)
  188. res.data.forEach((item,index) => {
  189. if(item.num > 0) {
  190. dates.push({
  191. year: calendar.getCurrentYM().year,
  192. month: calendar.getCurrentYM().month,
  193. date: item.day
  194. })
  195. }
  196. console.log(item)
  197. })
  198. calendar.setSelectedDates(dates)
  199. console.log(dates)
  200. console.log(res)
  201. })
  202. }
  203. })