assess.js 4.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208
  1. const api = require('../../../utils/api.js');
  2. const login = require('../../../utils/index.js');
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. items: [{ 'index': 1, 'name': '非常不满意' }, { 'index': 2, 'name': '不满意' }, { 'index': 2, 'name': '一般' }, { 'index': 3, 'name': '满意' }, { 'index': 4, 'name': '非常满意' }],
  9. tab:['已评价','未评价'],
  10. cur_index:0,
  11. page:1,
  12. page1:1,
  13. type:1,
  14. list:[],
  15. list1:[],
  16. tab_index:0
  17. },
  18. assess:function(e){
  19. wx.navigateTo({
  20. url: e.currentTarget.dataset.url,
  21. })
  22. },
  23. /**
  24. * 生命周期函数--监听页面加载
  25. */
  26. onLoad: function (options) {
  27. let that=this
  28. // wx.setStorageSync('userId', 92)
  29. var query = wx.createSelectorQuery();
  30. //选择id
  31. query.select('.menus').boundingClientRect();
  32. query.exec(function (res) {
  33. that.data.topHeight = res[0].height
  34. wx.getSystemInfo({
  35. success: function (res) {
  36. that.setData({
  37. clientHeight: res.windowHeight - that.data.topHeight
  38. });
  39. }
  40. })
  41. })
  42. let getUserInfo = login.default.getUserInfo();
  43. getUserInfo.then((resolve) => {
  44. that.data.userInfo = resolve
  45. if (!that.data.userInfo.id) {
  46. return false
  47. }
  48. that.req()
  49. })
  50. },
  51. req:function(){
  52. let that=this
  53. wx.showLoading({
  54. title: '正在加载',
  55. })
  56. wx.request({
  57. url: api.evaluateList,
  58. data: { userId: that.data.userInfo.id, status: that.data.type, page: that.data.type == 1 ? that.data.page : that.data.page1, rows: 20 },
  59. success(res) {
  60. wx.hideLoading();
  61. if(that.data.type==1){
  62. if (res.data.data.items.length < 20) {
  63. that.data.isno = true
  64. }
  65. if (that.data.list) {
  66. for (let i = 0; i < res.data.data.items.length; i++) {
  67. that.data.list.push(res.data.data.items[i])
  68. }
  69. } else {
  70. that.data.list = res.data.data.items
  71. }
  72. that.setData({
  73. list: that.data.list,
  74. dixian1: res.data.data.items.length < 20?true:false
  75. })
  76. }else{
  77. if (res.data.data.items.length < 20) {
  78. that.data.isno1 = true
  79. }
  80. if (that.data.list1) {
  81. for (let i = 0; i < res.data.data.items.length; i++) {
  82. that.data.list1.push(res.data.data.items[i])
  83. }
  84. } else {
  85. that.data.list1 = res.data.data.items
  86. }
  87. that.setData({
  88. list1: that.data.list1,
  89. dixian2: res.data.data.items.length < 20 ? true : false
  90. })
  91. }
  92. }
  93. })
  94. },
  95. scrollbot:function(){
  96. let that = this
  97. if(that.data.type==1){
  98. if (that.data.isno) {
  99. // wx.showToast({
  100. // title: '没有更多了',
  101. // icon: 'none'
  102. // })
  103. that.setData({
  104. dixian1: true
  105. })
  106. return false;
  107. }
  108. } else if (that.data.type==0){
  109. if (that.data.isno1) {
  110. // wx.showToast({
  111. // title: '没有更多了',
  112. // icon: 'none'
  113. // })
  114. that.setData({
  115. dixian2:true
  116. })
  117. return false;
  118. }
  119. }
  120. if(that.data.type==1){
  121. that.data.page = that.data.page + 1
  122. }else{
  123. that.data.page1 = that.data.page1 + 1
  124. }
  125. that.req()
  126. },
  127. meunTap:function(e){
  128. this.setData({
  129. cur_index:e.currentTarget.dataset.index,
  130. tab_index: e.currentTarget.dataset.index,
  131. })
  132. },
  133. swiperChange:function(e){
  134. var that = this
  135. if (e.detail.current == 0) {
  136. this.data.type = 1
  137. if (that.data.list.length == 0) {
  138. that.req()
  139. }
  140. } else if (e.detail.current == 1) {
  141. this.data.type = 0
  142. if(that.data.list1.length==0){
  143. that.req()
  144. }
  145. }
  146. e.currentTarget.dataset.index = e.detail.current
  147. this.meunTap(e);
  148. this.setData({
  149. tab_index: e.detail.current
  150. })
  151. },
  152. nav:function(e){
  153. wx.navigateTo({
  154. url: e.currentTarget.dataset.url
  155. })
  156. },
  157. /**
  158. * 生命周期函数--监听页面初次渲染完成
  159. */
  160. onReady: function () {
  161. let that=this
  162. },
  163. /**
  164. * 生命周期函数--监听页面显示
  165. */
  166. onShow: function () {
  167. },
  168. /**
  169. * 生命周期函数--监听页面隐藏
  170. */
  171. onHide: function () {
  172. },
  173. /**
  174. * 生命周期函数--监听页面卸载
  175. */
  176. onUnload: function () {
  177. },
  178. /**
  179. * 页面相关事件处理函数--监听用户下拉动作
  180. */
  181. onPullDownRefresh: function () {
  182. },
  183. /**
  184. * 页面上拉触底事件的处理函数
  185. */
  186. onReachBottom: function () {
  187. },
  188. /**
  189. * 用户点击右上角分享
  190. */
  191. onShareAppMessage: function () {
  192. }
  193. })