美甲小程序
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

278 lignes
5.4 KiB

  1. // pages/detailContent/detailContent.js
  2. const utils = require('../../utils/serve')
  3. Page({
  4. /**
  5. * 页面的初始数据
  6. */
  7. data: {
  8. searchData: [
  9. ],
  10. isItem: 3,
  11. gramNum: null,
  12. paginate: null,
  13. rightStatus: true,
  14. leftStatus: true,
  15. hLoading: true,
  16. },
  17. /**
  18. * 生命周期函数--监听页面加载
  19. */
  20. onLoad: function (options) {
  21. let obj = JSON.parse(options.obj)
  22. this.initOn(obj)
  23. },
  24. skipSearch: function () {
  25. wx.navigateTo({
  26. url: '/pages/pageSearch/pageSearch',
  27. })
  28. },
  29. getImg( ev){
  30. wx.previewImage({
  31. current: '',
  32. urls: [ev.currentTarget.dataset.img]
  33. })
  34. },
  35. // 右滑翻页
  36. onbolwerRight: function () {
  37. console.log(this.data.searchData[this.data.searchData.length - 1])
  38. this.setData({
  39. hLoading: false
  40. })
  41. if (this.data.rightStatus) {
  42. utils.http({
  43. url: '/manicureApi/Index/finishedProduct',
  44. method: 'GET',
  45. data: {
  46. id: this.data.searchData[this.data.searchData.length - 1].id,
  47. type: 'right'
  48. }
  49. }).then(res => {
  50. if (res.data.lists.length === 0) {
  51. wx.showToast({
  52. title: '已经到底啦~',
  53. duration: 2000,
  54. icon: 'none',
  55. success: () => {
  56. this.setData({
  57. hLoading: true
  58. })
  59. }
  60. })
  61. return
  62. }
  63. if (res.data.lists.length >= 1 && res.data.lists.length === 20) {
  64. this.data.rightStatus = true
  65. } else {
  66. this.data.rightStatus = false
  67. }
  68. this.setData({
  69. searchData: this.data.searchData.concat(res.data.lists),
  70. hLoading: true
  71. })
  72. })
  73. } else {
  74. wx.showToast({
  75. title: '已经到低啦~',
  76. duration: 2000,
  77. icon: 'none',
  78. success:()=>{
  79. this.setData({
  80. hLoading: true
  81. })
  82. }
  83. })
  84. }
  85. },
  86. // 左翻页
  87. onbolwerLeft: function () {
  88. this.setData({
  89. hLoading: false
  90. })
  91. if (this.data.leftStatus) {
  92. utils.http({
  93. url: '/manicureApi/Index/finishedProduct',
  94. method: 'GET',
  95. data: {
  96. id: this.data.searchData[0].id,
  97. type: 'left'
  98. }
  99. }).then(res => {
  100. if (res.data.lists.length >= 1 && res.data.lists.length === 20) {
  101. this.data.leftStatus = true
  102. } else {
  103. this.data.leftStatus = false
  104. }
  105. this.setData({
  106. searchData: res.data.lists.concat(this.data.searchData),
  107. hLoading: true
  108. })
  109. })
  110. } else {
  111. wx.showToast({
  112. title: '已经到顶了~',
  113. duration: 2000,
  114. icon: 'none',
  115. success:()=>{
  116. this.setData({
  117. hLoading: true
  118. })
  119. }
  120. })
  121. }
  122. },
  123. onSwiperItem: function (ev) {
  124. this.setData({
  125. isItem: ev.detail.current
  126. })
  127. },
  128. initOn: function (params) {
  129. // eventChannel.on('acceptDataFromOpenerPage', (data, list, paginate, finData) => {
  130. let isItem = 0;
  131. for (let i = 0; i < params.searchData.length; i++) {
  132. if ( params.searchData[i].id === params.param.id) {
  133. isItem = i
  134. break
  135. }
  136. }
  137. if (isItem <= 1) {
  138. utils.http({
  139. url: '/manicureApi/Index/finishedProduct',
  140. method: 'GET',
  141. data: {
  142. id: params.searchData[0].id,
  143. type: 'left'
  144. }
  145. }).then(res => {
  146. if (res.data.lists.length >= 1 && res.data.lists.length === 20) {
  147. this.data.leftStatus = true
  148. } else {
  149. this.data.leftStatus = false
  150. }
  151. this.setData({
  152. searchData: res.data.lists.concat( params.searchData ),
  153. isItem: isItem + res.data.lists.length
  154. }, () => {
  155. this.data.paginate = params.paginate
  156. this.data.finData = params.finData
  157. })
  158. })
  159. } else {
  160. this.setData({
  161. searchData: params.searchData,
  162. isItem: isItem
  163. }, () => {
  164. this.data.paginate = params.paginate
  165. this.data.finData = params.finData
  166. })
  167. }
  168. // })
  169. },
  170. setSearchColor: function (ev) {
  171. this.setData({
  172. isItem: ev.currentTarget.dataset.index
  173. })
  174. },
  175. skipInquire: function () {
  176. console.log(this.data.searchData)
  177. utils.http({
  178. url: '/manicureApi/Index/productDetail',
  179. method: 'GET',
  180. data: {
  181. id: this.data.searchData[this.data.isItem].id,
  182. num: this.data.gramNum,
  183. }
  184. }).then(res => {
  185. console.log(res)
  186. let data = JSON.stringify(res.data)
  187. wx.navigateTo({
  188. url: `/pages/pageInquire/pageInquire?data=${data}`,
  189. })
  190. })
  191. },
  192. onInputGram: function (ev) {
  193. this.data.gramNum = ev.detail.value
  194. },
  195. /**
  196. * 生命周期函数--监听页面初次渲染完成
  197. */
  198. onReady: function () {
  199. },
  200. /**
  201. * 生命周期函数--监听页面显示
  202. */
  203. onShow: function () {
  204. },
  205. /**
  206. * 生命周期函数--监听页面隐藏
  207. */
  208. onHide: function () {
  209. },
  210. /**
  211. * 生命周期函数--监听页面卸载
  212. */
  213. onUnload: function () {
  214. },
  215. /**
  216. * 页面相关事件处理函数--监听用户下拉动作
  217. */
  218. onPullDownRefresh: function () {
  219. },
  220. /**
  221. * 页面上拉触底事件的处理函数
  222. */
  223. onReachBottom: function () {
  224. },
  225. /**
  226. * 用户点击右上角分享
  227. */
  228. onShareAppMessage: function () {
  229. }
  230. })