add polyfill to support find findIndex methods, bugfix display price

wechat_user_type
Ge Hao 8 years ago
parent fb252e1284
commit 9b61bc02c5
  1. 4
      app.js
  2. 4
      pages/mine/mine.wxml
  3. 2
      pages/show_product/show_product.wxml
  4. 54
      utils/polyfill.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')

@ -6,7 +6,7 @@
<view wx:if="{{baye_rank}}">
<view class='xunzhang'>
<image src="{{xunZhang}}" mode="aspectFit"></image>
<view class="rank"><text>{{baye_rank || ''}}</text></view>
<view class="rank"><text>{{baye_rank ? baye_rank : ''}}</text></view>
</view>
</view>
</view>
@ -56,4 +56,4 @@
<view>》</view>
</view>-->
</view>
</view>
</view>

@ -9,7 +9,7 @@
<form>
<view class="line">
<view class="section price">
<text id="price">¥{{product.price || '无法获取价格'}}</text>
<text id="price">¥{{product.price}}</text>
</view>
<view class="section quantity">
<view>购买数量:</view>

@ -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;
}
});
}
Loading…
Cancel
Save