前几年就有人fail怎么现在还fail.
看了官方指引 开了JS 转ES5 也更新了 没用 谢谢大神解答。
https:
TypeError: Function(...) is not a function
at runtime.js? [sm]:747
at WASubContext.js?t=wechat&s=1752280867204&v=3.8.3:1
at _.runWith (WASubContext.js?t=wechat&s=1752280867204&v=3.8.3:1)
at q (WASubContext.js?t=wechat&s=1752280867204&v=3.8.3:1)
at n (WASubContext.js?t=wechat&s=1752280867204&v=3.8.3:1)
at index.js? [sm]:3
at WASubContext.js?t=wechat&s=1752280867204&v=3.8.3:1
at _.runWith (WASubContext.js?t=wechat&s=1752280867204&v=3.8.3:1)
at q (WASubContext.js?t=wechat&s=1752280867204&v=3.8.3:1)
at appservice.js:1403(env: Windows,mp,1.06.2405020; lib: 3.8.3)



import{getSetting,chooseAddress,openSetting,showModal,showToast } from "../../utils/asyncWx.js";
import regeneratorRuntime from '../../lib/runtime/runtime';
import {accAdd,accMul} from "../../utils/util.js";
Page({
data: {
address:{},
cart:[],
allChecked:false,
totalPrice:0,
totalNum:0,
curSchoolName:'',
},
onShow:function(){
const address=wx.getStorageSync("curAddr")||[];
this.setData({address});
const cart=wx.getStorageSync("cart")||[];
this.setCart(cart);
this.scanCart(this);
},
async handleChooseAddress(){
wx.navigateTo({
url: '/pages/address/index'
})
},
handleItemChange(e){
const cl_id=e.currentTarget.dataset.id;
console.log(cl_id);
let {cart}=this.data;
let index=cart.findIndex(v=>v.cloth_id===cl_id);
cart[index].checked=!cart[index].checked;
this.setCart(cart);
this.scanCart(this)
},
setCart(cart){
let allChecked=true;
let totalPrice=0;
let totalNum=0;
cart.forEach(v=>{
if(v.checked){
totalPrice=accAdd(accMul(v.num,v.cloth_price),totalPrice);
totalNum+=v.num;
}
else{
allChecked=false;
}
})
allChecked=cart.length!=0?allChecked:false;
this.setData({
cart,
allChecked,
totalPrice,
totalNum
});
wx.setStorageSync('cart', cart);
},
handleAlhandleItemAllChecklChange(){
let {cart,allChecked}=this.data;
allChecked=!allChecked;
cart.forEach(v=>v.checked=allChecked);
this.setCart(cart);
this.scanCart(this)
},
async handleItemNumEdit(e){
const {operation,id}=e.currentTarget.dataset;
let {cart}=this.data;
const index=cart.findIndex(v=>v.cloth_id===id);
if(cart[index].num===1&&operation===-1){
const res=await showModal({content:"您确定要删除商品吗?"})
if (res.confirm) {
cart.splice(index,1);
this.setCart(cart);
}
}
if(cart[index].num===2&&operation===+1&&(
wx.getStorageSync("curschool")['_id']==101004
||wx.getStorageSync("curschool")['_id']==101005
||wx.getStorageSync("curschool")['_id']==101002)
&&cart[index].cloth_class==2025
)
{
await showToast({title:""});
return;
}
else {
cart[index].num+=operation;
this.setCart(cart);
}
this.scanCart(this)
},
async handleSubmit(){
const {address,totalNum}=this.data;
if(!address.receiver){
await showToast({title:"您还没有选择收货地址"});
return;
}
if(totalNum===0){
await showToast({title:"您还没有选择商品"});
return;
}
if((totalNum!=4
||wx.getStorageSync("cart")[0]['cloth_name']==wx.getStorageSync("cart")[1]['cloth_name']
||wx.getStorageSync("cart")[0]['cloth_class']!=wx.getStorageSync("cart")[1]['cloth_class']
||wx.getStorageSync("cart")[0]['cloth_grade']!=wx.getStorageSync("cart")[1]['cloth_grade']
||wx.getStorageSync("cart")[0]['cloth_gender']!=wx.getStorageSync("cart")[1]['cloth_gender']
)
&&(wx.getStorageSync("curschool")['_id']==101004
||wx.getStorageSync("curschool")['_id']==101005
||wx.getStorageSync("curschool")['_id']==101002)
&& wx.getStorageSync("cart")[0]['cloth_class']==2025)
{
await showToast({title:""});
return;
}
wx.navigateTo({
url: '/pages/submit/index',
})
},
scanCart: function (that) {
var cart = wx.getStorageSync("cart");
var cartnumber = 0;
for (var index in cart) {
cartnumber += cart[index].num
}
if (cart.length) {
wx.setTabBarBadge({
index: 1,
text: "" + cartnumber + ""
})
} else {
wx.removeTabBarBadge({
index: 1,
})
}
}
})