jd-opensource / jd-opensource/taro-ui
AtInputNumber 在微信小程序端 有🙅♂️问题
- Dominant language
- TypeScript
- Stars
- 4.7k
- Forks
- 740
- PR merge metrics
- No merged PRs in 30d
Description
```js
import Taro, {useEffect, useState} from "@tarojs/taro";
import {Image, Swiper, SwiperItem, Text, View} from "@tarojs/components";
import './index.scss';
import {ClShopBar, ClCard, ClDrawer, ClFlex, ClButton} from 'mp-colorui';
import {AtInputNumber, AtModal} from 'taro-ui';
import {getGoodInfoById} from "../../http_datas/GoodData";
import {auth} from "../../http_datas/AuthData";
import {cartAdd} from "../../http_datas/CartData";
import {redirectTo} from "../../utils/redirect";
function Product() {
const self = this;
const [info, setInfo]: [any, any] = useState({
good: {},
goods_attr_list: []
});
const [swipers, setSwipers] = useState([]);
const [inputNumber, setInputNumber] = useState(1);
const [show, setShow] = useState(false);
const [isOpened, setIsOpened] = useState({
opened: false,
content: ''
});
useEffect(function () {
const init = async () => {
let res = await getGoodInfoById(self.$router.params.id);
setInfo(res);
let nswipers = res.goods_images_list.map(v => {
return {
type: 'image',
url: v
};
});
setSwipers(nswipers);
Taro.setNavigationBarTitle({
title: res.good.goods_name
});
}
init();
}, []);
const drawerHandle = (index) => {
console.log(index);
setShow(true);
}
const addCart = async () => {
auth();
let result = await cartAdd({
id: info.good.goods_id,
num: inputNumber
});
if (result === 1) {
setShow(false);
setIsOpened(prevState => Object.assign(prevState, {opened: true, content: '加入成功'}));
} else {
setIsOpened(prevState => Object.assign(prevState, {opened: true, content: '加入失败'}));
}
}
const handleClose = () => {
setIsOpened(prevState => Object.assign(prevState, {opened: false}));
}
const handleConfirm = () => {
redirectTo('pages/index', {index: 3});
}
return (
{swipers.map((v: any) => (
))}
{info.good && info.good.scene_img_url && (
实拍图
)}
{info.goods_content_images && (
项目案例
{
info.goods_content_images.map(v => (
))
}
)}
{info.good.goods_name}
¥{info.good.shop_price}
{
setInputNumber(value)
}}
/>
确认
drawerHandle(index)}
/>
)
}
export default Product;
```
{
"name": "mitooAp",
"version": "1.0.0",
"private": true,
"description": "明图电商",
"templateInfo": {
"name": "default",
"typescript": true,
"css": "sass"
},
"scripts": {
"build:weapp": "taro build --type weapp",
"build:swan": "taro build --type swan",
"build:alipay": "taro build --type alipay",
"build:tt": "taro build --type tt",
"build:h5": "taro build --type h5",
"build:rn": "taro build --type rn",
"build:qq": "taro build --type qq",
"build:quickapp": "taro build --type quickapp",
"dev:weapp": "npm run build:weapp -- --watch",
"dev:swan": "npm run build:swan -- --watch",
"dev:alipay": "npm run build:alipay -- --watch",
"dev:tt": "npm run build:tt -- --watch",
"dev:h5": "npm run build:h5 -- --watch",
"dev:rn": "npm run build:rn -- --watch",
"dev:qq": "npm run build:qq -- --watch",
"dev:quickapp": "npm run build:quickapp -- --watch"
},
"author": "",
"license": "MIT",
"dependencies": {
"@tarojs/async-await": "^1.3.14",
"@tarojs/components": "1.3.14",
"@tarojs/router": "1.3.14",
"@tarojs/taro": "1.3.14",
"@tarojs/taro-alipay": "1.3.14",
"@tarojs/taro-h5": "1.3.14",
"@tarojs/taro-qq": "1.3.14",
"@tarojs/taro-quickapp": "1.3.14",
"@tarojs/taro-swan": "1.3.14",
"@tarojs/taro-tt": "1.3.14",
"@tarojs/taro-weapp": "1.3.14",
"mp-colorui": "^0.4.1",
"nerv-devtools": "^1.4.0",
"nervjs": "^1.4.0",
"taro-axios": "^0.5.1",
"taro-ui": "^2.2.2",
"weixin-js-sdk": "^1.4.0-test"
},
"devDependencies": {
"@tarojs/plugin-babel": "1.3.14",
"@tarojs/plugin-csso": "1.3.14",
"@tarojs/plugin-sass": "1.3.14",
"@tarojs/plugin-uglifyjs": "1.3.14",
"@tarojs/webpack-runner": "1.3.14",
"@types/react": "^16.4.6",
"@types/webpack-env": "^1.13.6",
"@typescript-eslint/parser": "^1.6.0",
"babel-eslint": "^8.2.3",
"babel-plugin-transform-class-properties": "^6.24.1",
"babel-plugin-transform-decorators-legacy": "^1.3.4",
"babel-plugin-transform-jsx-stylesheet": "^0.6.5",
"babel-plugin-transform-object-rest-spread": "^6.26.0",
"babel-preset-env": "^1.6.1",
"eslint": "^5.16.0",
"eslint-config-taro": "1.3.14",
"eslint-plugin-import": "^2.12.0",
"eslint-plugin-react": "^7.8.2",
"eslint-plugin-react-hooks": "^1.6.1",
"eslint-plugin-taro": "1.3.14",
"stylelint": "9.3.0",
"stylelint-config-taro-rn": "1.3.14",
"stylelint-taro-rn": "1.3.14",
"typescript": "^3.0.1"
}
}

Contributor guide
Assessment
This issue has not been assessed yet.