address.vue 5.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267
  1. <template>
  2. <view>
  3. <!-- 头部 -->
  4. <headContent borderBottom>
  5. <template #left>
  6. <reverse-back />
  7. </template>
  8. <template #right>
  9. <view class="head-icon" @click.stop="selectCurrency()">
  10. <text class="iconfont">&#xe671;</text>
  11. </view>
  12. </template>
  13. </headContent>
  14. <view class="content" :style="{'height':PageContentHeight + 'px'}">
  15. <view class="pages-title">
  16. 地址管理
  17. </view>
  18. <view class="currency">
  19. <text class="currency-lable">{{ currencyInfo ? currencyInfo.name : '' }}</text>
  20. <u-switch space="4" v-model="value11" activeColor="#05C175" inactiveColor="rgb(226, 226, 226)"
  21. size="30"></u-switch>
  22. </view>
  23. <scroll-view class="scroll-view" scroll-y :style="{'height': scrollHeight}">
  24. <template v-for="(item , index) in addressList">
  25. <view class="address-item">
  26. <view class="address-title">
  27. <text class="title">{{ item.notes }}</text>
  28. <text class="del-address" @click.stop="delAddress(item)">删除</text>
  29. </view>
  30. <view class="address-currency">
  31. {{ currencyInfo ? `${currencyInfo.name}_` : '' }}{{ item.type }}
  32. </view>
  33. <view class="address-text">
  34. {{ item.address }}
  35. </view>
  36. </view>
  37. </template>
  38. </scroll-view>
  39. <view class="add-address">
  40. <view class="add-btn" @click.stop="addBtn()">
  41. 添加提币地址
  42. </view>
  43. </view>
  44. </view>
  45. <confirm-popup ref="confirmPopupRef" content="确定删除?" @confirm="confirmDel" />
  46. </view>
  47. </template>
  48. <script>
  49. import {
  50. mapGetters
  51. } from 'vuex'
  52. import {
  53. Way_getBiTypeList
  54. } from "@/utils/common-request.js"
  55. import {
  56. Api_getAddress,
  57. Api_delAddress
  58. } from "@/api/index.js"
  59. export default {
  60. name: 'addressList',
  61. data() {
  62. return {
  63. value11: false,
  64. scrollHeight: 0,
  65. currencyInfo: null,
  66. addressList: [],
  67. getBiStatus: false,
  68. delItem: {},
  69. };
  70. },
  71. computed: {
  72. ...mapGetters([
  73. 'PageContentHeight'
  74. ])
  75. },
  76. watch: {
  77. PageContentHeight: {
  78. handler(newH) {
  79. this.scrollHeight = newH - uni.upx2px(120) - uni.upx2px(80) - uni.upx2px(160) + 'px'
  80. },
  81. immediate: true
  82. },
  83. currencyInfo: {
  84. handler(newC, oldC) {
  85. if (newC && newC.id !== oldC?.id) {
  86. this.getAddress();
  87. this.$setStorageSync('currency', newC);
  88. } else {
  89. if (this.getBiStatus) {
  90. return false
  91. };
  92. this.getBiStatus = true;
  93. Way_getBiTypeList().then(res => {
  94. if (res && res.length > 0) {
  95. this.currencyInfo = res[0];
  96. this.getBiStatus = false
  97. }
  98. }).catch(err => {
  99. this.currencyInfo = []
  100. })
  101. }
  102. },
  103. deep: true,
  104. immediate: true
  105. },
  106. },
  107. onLoad() {
  108. this.currencyInfo = this.$getStorageSync('currency');
  109. },
  110. onShow() {
  111. },
  112. mounted() {
  113. },
  114. methods: {
  115. confirmDel() {
  116. uni.showLoading({
  117. title: ''
  118. })
  119. Api_delAddress({
  120. address_id: this.delItem?.id
  121. }).then(res => {
  122. this.getAddress()
  123. }).catch(err => {
  124. }).finally(() => {
  125. setTimeout(() => {
  126. uni.hideLoading()
  127. }, 200)
  128. })
  129. },
  130. // 删除
  131. delAddress(item) {
  132. this.delItem = item
  133. this.$nextTick(() => {
  134. this.$refs.confirmPopupRef.open();
  135. })
  136. },
  137. selectCurrency() {
  138. uni.navigateTo({
  139. url: `/pages/content/select-currency?type=address`
  140. })
  141. },
  142. addBtn() {
  143. uni.navigateTo({
  144. url: '/pages/content/add-address',
  145. success: res => {
  146. // 通过eventChannel向被打开页面传送数据
  147. res.eventChannel.emit('setCurrency', this.currencyInfo)
  148. }
  149. })
  150. },
  151. getAddress() {
  152. Api_getAddress({
  153. currency: this.currencyInfo?.id
  154. }).then(res => {
  155. this.addressList = res
  156. console.log('getAddress = ', res)
  157. }).catch(err => {
  158. })
  159. }
  160. }
  161. }
  162. </script>
  163. <style lang="scss" scoped>
  164. .content {
  165. width: 100%;
  166. .pages-title {
  167. height: 120rpx;
  168. font-size: 60rpx;
  169. font-weight: bold;
  170. line-height: 130rpx;
  171. padding: 0 $pages-padding;
  172. }
  173. .currency {
  174. width: 100%;
  175. height: 80rpx;
  176. padding: 0 $pages-padding;
  177. display: flex;
  178. justify-content: space-between;
  179. .currency-lable {
  180. font-size: 28rpx;
  181. }
  182. }
  183. .scroll-view {
  184. width: 100%;
  185. padding: 0 $pages-padding;
  186. .address-item {
  187. width: 100%;
  188. background-color: #f6f6f6;
  189. padding: 36rpx 20rpx;
  190. border-radius: 10rpx;
  191. margin-bottom: 20rpx;
  192. .address-title {
  193. width: 100%;
  194. border-bottom: 1rpx solid $border-color4;
  195. padding-bottom: 30rpx;
  196. display: flex;
  197. justify-content: space-between;
  198. .title {
  199. flex: 1;
  200. font-size: 30rpx;
  201. }
  202. .del-address {
  203. flex-shrink: 0;
  204. font-size: 26rpx;
  205. color: #d7b213;
  206. }
  207. }
  208. .address-currency {
  209. padding: 20rpx 0 16rpx;
  210. font-size: 24rpx;
  211. color: #aaa8a8;
  212. }
  213. .address-text {
  214. font-size: 22rpx;
  215. color: #aaa8a8;
  216. }
  217. }
  218. // <view class="address-item">
  219. // <view class="address-title">
  220. // <text class="title">发个按时打卡可是大家撒低级</text>
  221. // <text class="del-address">删除</text>
  222. // </view>
  223. // <view class="address-currency">
  224. // USDT_TRC20
  225. // </view>
  226. // <view class="address-text">
  227. // 的军事打击跨国黄金时代进口的韩国
  228. // </view>
  229. // </view>
  230. }
  231. .add-address {
  232. width: 100%;
  233. height: 160rpx;
  234. padding: 40rpx $pages-padding;
  235. .add-btn {
  236. width: 100%;
  237. height: 100%;
  238. text-align: center;
  239. line-height: 80rpx;
  240. background-color: $Theme-Color;
  241. font-size: 32rpx;
  242. color: #fff;
  243. border-radius: 10rpx;
  244. }
  245. }
  246. }
  247. </style>