| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114 |
- var _request = require('../../../utils/request.js')
- Page({
- data: {
- price: 0,
- count: 0,
- min: 0,
- retrieve: 0,
- sell: 0,
- self_count: 1,
- re_count: 1,
- re_max: 0,
- re_price: 0,
- sell_sount: 0,
- all: 0
- },
- onLoad: function (options) {
- console.log(options)
- this.setData({
- price: Number(options.price),
- count: Number(options.count),
- min: Number(options.min) * ((Number(options.count) - Number(options.minlimit)) / Number(options.limit) + 1),
- retrieve: Number(options.retrieve),
- sell: Number(options.sell),
- re_max: Number(options.remax),
- re_price: Number(options.reprice)
- })
- this.setData({
- self_count: this.data.min
- })
- if (Number(options.count) - this.data.min > this.data.re_max) {
- this.setData({
- re_count: this.data.re_max
- })
- } else {
- this.setData({
- re_count: Number(options.count) - this.data.min
- })
- }
- this.setData({
- sell_sount: this.data.count - this.data.self_count - this.data.re_count
- })
- this.changeSell()
- },
- selfSub: function () {
- if (this.data.self_count > this.data.min) {
- let count = this.data.self_count - 1
- this.setData({
- self_count: count
- })
- this.changeSell()
- }
- },
- selfAdd: function () {
- if (this.data.self_count + this.data.re_count >= this.data.count && this.data.re_count > 0) {
- let add = this.data.self_count + 1
- let sub = this.data.re_count - 1
- this.setData({
- self_count: add,
- re_count: sub
- })
- this.changeSell()
- } else if (this.data.self_count + this.data.re_count < this.data.count) {
- let add = this.data.self_count + 1
- this.setData({
- self_count: add
- })
- this.changeSell()
- }
- },
- reSub: function () {
- if (this.data.re_count > 0) {
- let count = this.data.re_count - 1
- this.setData({
- re_count: count
- })
- this.changeSell()
- }
- },
- reAdd: function () {
- if (this.data.re_count < this.data.re_max) {
- if (this.data.self_count + this.data.re_count >= this.data.count && this.data.self_count > this.data.min) {
- let add = this.data.re_count + 1
- let sub = this.data.self_count - 1
- this.setData({
- re_count: add,
- self_count: sub
- })
- this.changeSell()
- } else if (this.data.self_count + this.data.re_count < this.data.count) {
- let add = this.data.re_count + 1
- this.setData({
- re_count: add
- })
- this.changeSell()
- }
- }
- },
- changeSell: function () {
- this.setData({
- sell_sount: this.data.count - this.data.self_count - this.data.re_count
- })
- // var a = ((((this.data.price / this.data.count * (this.data.re_count * (this.data.retrieve + 1) + this.data.self_count) + this.data.sell * this.data.sell_sount) / this.data.price) - 1) * 100).toFixed(2)
- var a = ((((this.data.price / this.data.count * this.data.self_count + this.data.re_count * this.data.re_price + this.data.sell * this.data.sell_sount) / this.data.price) - 1) * 100).toFixed(2)
- this.setData({
- all: a
- })
- },
- onShareAppMessage: function (val) {
- return _request.share({
- sc: 'helpfarm_calculate'
- })
- }
- })
|