|
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278 |
- // 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 () {
-
- }
- })
|