123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155 |
- import { View, Image, Switch, Radio, RadioGroup } from "@tarojs/components"
- import Taro, { useDidShow } from "@tarojs/taro"
- import { useState, useEffect, useMemo } from "react"
- import CustomNav from "@/components/CustomNav"
- import edit from "@/assets/icons/comm/edit.png"
- import userRight from '@/assets/mineImgaes/userRight.png'
-
- import deletes from "@/assets/icons/comm/deletes.png"
- import ButtontWX from '@/components/ButtontWX'
-
-
- import { addressDefault, getAddress, addressDelete, addressUpdate } from "@/services/address"
-
- import './style.less'
-
-
-
- export default (props) => {
- const [addresList, setAddresList] = useState([])
-
- const addAddress = () => {
- Taro.navigateTo({ url: `/pages/MyAddressList/AddressInfos/index?id=${1}` })
- }
-
- const addressDeletess = (e) => {
- Taro.showModal({
- title: '提示',
- content: '您确定要删除此地址吗',
- success: function (res) {
- if (res.confirm) {
- addressDelete(e).then((e) => {
- Taro.showToast({
- title: '地址删除成功',
- icon: 'success',
- duration: 2000
- })
- getList()
-
- })
- } else if (res.cancel) {
- console.log('用户点击取消')
- }
- }
- })
-
- }
- const [switchBool, setSwitchBool] = useState()
- // const [switchValue, setSwitchValue] = useState('')
-
- const handelSwitch = (a, e) => {
- const { value } = e.detail
- addressDefault(a).then((se) => {
- console.log('e', se);
- getList()
- })
- // if (value == '') {
- // setSwitchBool(!!value)
-
- // } else {
- // setSwitchBool(!value)
- // }
-
- }
- const addressEdit = (e, res) => {
- console.log('e', e);
- Taro.navigateTo({ url: `/pages/MyAddressList/AddressInfos/index?addressId=${e}&address=${res}` })
-
- }
-
-
-
- const getList = () => {
- getAddress().then((e) => {
- console.log('地址列表', e);
- // let abccList = e.records.sort((a, b) => b.isDefault - a.isDefault)
- // console.log("🚀 ~ file: index.jsx ~ line 75 ~ getAddress ~ abccList", abccList)
- setAddresList(e.records)
- })
- }
- useDidShow(() => {
- getList()
-
- })
-
- useEffect(() => {
- getList()
-
-
- }, [])
-
- const srcor = (e) => {
- console.log('评分', e.detail);
-
- }
-
- return (
- <View className='page-index'>
- <View className='index-navbar'>
- <CustomNav title='地址管理' />
- </View>
- <scroll-view scrollY style='height: 100%;' >
- <View>
- {/* <mp-orderRater raterChange={srcor} initW='50%' /> */}
- {
- addresList.map((item, index) => {
- return (
- <View className='addressList-box' key={index}>
- <View className='addressList-box-addressTop'>
- {
- item.isDefault ?
- <View className='addressList-box-addressTop-redText'>默认地址</View> : ''
- }
- <View className='addressList-box-addressTop-title'>我的地址{index + 1}</View>
- </View>
- <View className='addressList-box-addressBotton'>
- <View className='addressList-box-addressBotton-editTextImage'>
- <View>
- {item.address}
- </View>
- <Image src={edit} onClick={() => addressEdit(item.addressId, item.address)} />
- </View>
-
- <View className='addressList-box-addressBotton-setAddress'>
- <View>
- 设为默认地址:
- <RadioGroup className='radio-group' onChange={(res) => handelSwitch(item.addressId, res)} >
- <Radio color='#FC5531' checked={item.isDefault}></Radio>
- </RadioGroup>
- </View>
-
- <View className='addressList-box-addressBotton-addressDelete' onClick={() => addressDeletess(item.addressId)}>
- <View>
- 删除
- </View>
- <Image src={deletes} />
-
- </View>
- </View>
- </View>
- </View>
- )
- })
- }
-
- <View className='bottomButtom' >
- <ButtontWX onClick={addAddress} formType='submit' butText='+新增收货地址' butWidth={315} butHeight={49} butFontSize={16} butBorderRadius={49} />
- </View>
-
- </View>
- </scroll-view>
- </View >
- )
- }
-
|