| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108 |
- var _request = require('../../../../utils/request.js')
- Page({
- data: {
- page: 1,
- per_page: 10,
- productList: [],
- productTotal: 0,
- more: true,
- show: false,
- angle: 0,
- curIndex: 0
- },
- onLoad: function (options) {
- this.getIphoneX()
- this.getProductList()
- },
- onShow: function () {
- this.data.page = 1
- // this.getProductList()
- },
- toFarm() {
- wx.redirectTo({
- url: '/packageUser/pages/user/farm/farm'
- })
- },
- toSell(e) {
- wx.navigateTo({
- url: '/packageUser/pages/user/granary/use/use?tab=sell&order_id=' + e.currentTarget.dataset.id
- })
- },
- toBack(e) {
- wx.navigateTo({
- url: '/packageUser/pages/user/granary/use/use?tab=return&order_id=' + e.currentTarget.dataset.id
- })
- },
- toMine(e) {
- wx.navigateTo({
- url: '/packageUser/pages/user/granary/use/use?tab=mine&order_id=' + e.currentTarget.dataset.id
- })
- },
- toMine1(e) {
- wx.navigateTo({
- url: '/packageUser/pages/user/granary/use/use?tab=mine1&order_id=' + e.currentTarget.dataset.id
- })
- },
- review (e) {
- var that = this
- that.data.show = !that.data.show
- if (that.data.show) {
- that.data.angle = 180
- } else {
- that.data.angle = 0
- }
- that.data.curIndex = e.currentTarget.dataset.cur
- if (that.data.curIndex === e.currentTarget.dataset.cur) {
- that.setData({
- show: that.data.show,
- angle: that.data.angle,
- curIndex: that.data.curIndex
- })
- }
- },
- getProductList () {
- var that = this
- var url = 'v1/user/granaries'
- var params = {
- page: that.data.page,
- per_page: that.data.per_page,
- cache: false
- }
- var success = function (res) {
- var result = that.data.productList.concat(res.data.list || [])
- var listMore = res.data.list_count > that.data.productList.length
- that.setData({
- productList: result,
- more: listMore,
- productTotal: res.data.list_count
- })
- }
- _request.$get(url, params, success)
- },
- onReachBottom: function () {
- if (this.data.more) {
- var page = this.data.page + 1
- this.setData({
- page: page
- })
- this.getProductList()
- }
- },
- getIphoneX () {
- var that = this
- wx.getSystemInfo({
- success: function (res) {
- if (res.model.toLowerCase().indexOf('iphone x') > -1) {
- that.setData({
- value: 34
- })
- }
- }
- })
- },
- onShareAppMessage: function (val) {
- return _request.share({
- sc: 'xcx_user_granary'
- })
- }
- })
|