address.vue 5.5 KB

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