address.vue 5.5 KB

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