diff --git a/app.js b/app.js index 3709681..ec13deb 100644 --- a/app.js +++ b/app.js @@ -1,6 +1,8 @@ +const jsonApi = require('utils/jsonapi-datastore/dist/jsonapi-datastore.js') +require('utils/polyfill.js') + App({ onLaunch: function () { - const jsonApi = require('utils/jsonapi-datastore/dist/jsonapi-datastore.js') this.store = new(jsonApi.JsonApiDataStore) this.jsonModel = jsonApi.JsonApiDataStoreModel this.globalData.code = wx.getStorageSync('code') diff --git a/pages/mine/mine.wxml b/pages/mine/mine.wxml index 0c58ee7..daa546b 100644 --- a/pages/mine/mine.wxml +++ b/pages/mine/mine.wxml @@ -6,7 +6,7 @@ - {{baye_rank || ''}} + {{baye_rank ? baye_rank : ''}} @@ -56,4 +56,4 @@ --> - \ No newline at end of file + diff --git a/pages/show_product/show_product.wxml b/pages/show_product/show_product.wxml index 37c56f6..1ab2bca 100644 --- a/pages/show_product/show_product.wxml +++ b/pages/show_product/show_product.wxml @@ -9,7 +9,7 @@
- ¥{{product.price || '无法获取价格'}} + ¥{{product.price}} 购买数量: diff --git a/utils/polyfill.js b/utils/polyfill.js new file mode 100644 index 0000000..4a70701 --- /dev/null +++ b/utils/polyfill.js @@ -0,0 +1,54 @@ +if (!Array.prototype.findIndex) { + Object.defineProperty(Array.prototype, 'findIndex', { + value: function(predicate) { + 'use strict'; + if (this == null) { + throw new TypeError('Array.prototype.findIndex called on null or undefined'); + } + if (typeof predicate !== 'function') { + throw new TypeError('predicate must be a function'); + } + var list = Object(this); + var length = list.length >>> 0; + var thisArg = arguments[1]; + var value; + + for (var i = 0; i < length; i++) { + value = list[i]; + if (predicate.call(thisArg, value, i, list)) { + return i; + } + } + return -1; + }, + enumerable: false, + configurable: false, + writable: false + }); +} + +if (!Array.prototype.find) { + Object.defineProperty(Array.prototype, 'find', { + value: function(predicate) { + 'use strict'; + if (this == null) { + throw new TypeError('Array.prototype.find called on null or undefined'); + } + if (typeof predicate !== 'function') { + throw new TypeError('predicate must be a function'); + } + var list = Object(this); + var length = list.length >>> 0; + var thisArg = arguments[1]; + var value; + + for (var i = 0; i < length; i++) { + value = list[i]; + if (predicate.call(thisArg, value, i, list)) { + return value; + } + } + return undefined; + } + }); +}