address.vue 5.2 KB

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