clientInfo.js 4.9 KB

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