|
- // pages/detailContent/detailContent.js
- const utils = require('../../utils/serve')
-
- Page({
-
- /**
- * 页面的初始数据
- */
- data: {
- searchData: [
- ],
- isItem: 3,
- gramNum: null,
- paginate: null,
- rightStatus: true,
- leftStatus: true,
- hLoading: true,
- },
-
- /**
- * 生命周期函数--监听页面加载
- */
- onLoad: function (options) {
-
- let obj = JSON.parse(options.obj)
-
- this.initOn(obj)
- },
- skipSearch: function () {
- wx.navigateTo({
- url: '/pages/pageSearch/pageSearch',
- })
- },
-
-
- getImg( ev){
-
- wx.previewImage({
- current: '',
- urls: [ev.currentTarget.dataset.img]
- })
- },
-
-
- // 右滑翻页
- onbolwerRight: function () {
- console.log(this.data.searchData[this.data.searchData.length - 1])
- this.setData({
- hLoading: false
- })
-
-
- if (this.data.rightStatus) {
- utils.http({
- url: '/manicureApi/Index/finishedProduct',
- method: 'GET',
- data: {
- id: this.data.searchData[this.data.searchData.length - 1].id,
- type: 'right'
- }
- }).then(res => {
- if (res.data.lists.length === 0) {
- wx.showToast({
- title: '已经到底啦~',
- duration: 2000,
- icon: 'none',
- success: () => {
- this.setData({
- hLoading: true
- })
- }
- })
- return
- }
-
- if (res.data.lists.length >= 1 && res.data.lists.length === 20) {
- this.data.rightStatus = true
- } else {
- this.data.rightStatus = false
- }
-
- this.setData({
- searchData: this.data.searchData.concat(res.data.lists),
- hLoading: true
- })
- })
- } else {
- wx.showToast({
- title: '已经到低啦~',
- duration: 2000,
- icon: 'none',
- success:()=>{
- this.setData({
- hLoading: true
- })
- }
- })
- }
- },
-
-
- // 左翻页
- onbolwerLeft: function () {
-
- this.setData({
- hLoading: false
- })
-
- if (this.data.leftStatus) {
- utils.http({
- url: '/manicureApi/Index/finishedProduct',
- method: 'GET',
- data: {
- id: this.data.searchData[0].id,
- type: 'left'
- }
- }).then(res => {
- if (res.data.lists.length >= 1 && res.data.lists.length === 20) {
- this.data.leftStatus = true
- } else {
- this.data.leftStatus = false
- }
-
-
-
- this.setData({
- searchData: res.data.lists.concat(this.data.searchData),
- hLoading: true
- })
- })
- } else {
- wx.showToast({
- title: '已经到顶了~',
- duration: 2000,
- icon: 'none',
- success:()=>{
- this.setData({
- hLoading: true
- })
- }
- })
- }
- },
-
-
- onSwiperItem: function (ev) {
- this.setData({
- isItem: ev.detail.current
- })
- },
-
-
-
- initOn: function (params) {
-
- // eventChannel.on('acceptDataFromOpenerPage', (data, list, paginate, finData) => {
-
- let isItem = 0;
- for (let i = 0; i < params.searchData.length; i++) {
- if ( params.searchData[i].id === params.param.id) {
- isItem = i
- break
- }
- }
- if (isItem <= 1) {
- utils.http({
- url: '/manicureApi/Index/finishedProduct',
- method: 'GET',
- data: {
- id: params.searchData[0].id,
- type: 'left'
- }
- }).then(res => {
- if (res.data.lists.length >= 1 && res.data.lists.length === 20) {
- this.data.leftStatus = true
- } else {
- this.data.leftStatus = false
- }
- this.setData({
- searchData: res.data.lists.concat( params.searchData ),
- isItem: isItem + res.data.lists.length
- }, () => {
- this.data.paginate = params.paginate
- this.data.finData = params.finData
- })
- })
- } else {
- this.setData({
- searchData: params.searchData,
- isItem: isItem
- }, () => {
- this.data.paginate = params.paginate
- this.data.finData = params.finData
- })
- }
- // })
- },
-
- setSearchColor: function (ev) {
-
- this.setData({
- isItem: ev.currentTarget.dataset.index
- })
- },
-
-
- skipInquire: function () {
- console.log(this.data.searchData)
- utils.http({
- url: '/manicureApi/Index/productDetail',
- method: 'GET',
- data: {
- id: this.data.searchData[this.data.isItem].id,
- num: this.data.gramNum,
- }
- }).then(res => {
- console.log(res)
- let data = JSON.stringify(res.data)
- wx.navigateTo({
- url: `/pages/pageInquire/pageInquire?data=${data}`,
- })
- })
- },
-
-
- onInputGram: function (ev) {
- this.data.gramNum = ev.detail.value
- },
-
- /**
- * 生命周期函数--监听页面初次渲染完成
- */
- onReady: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面显示
- */
- onShow: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面隐藏
- */
- onHide: function () {
-
- },
-
- /**
- * 生命周期函数--监听页面卸载
- */
- onUnload: function () {
-
- },
-
- /**
- * 页面相关事件处理函数--监听用户下拉动作
- */
- onPullDownRefresh: function () {
-
- },
-
- /**
- * 页面上拉触底事件的处理函数
- */
- onReachBottom: function () {
-
- },
-
- /**
- * 用户点击右上角分享
- */
- onShareAppMessage: function () {
-
- }
- })
|