receive.vue 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199
  1. <!-- 奖品领取 -->
  2. <template>
  3. <s-layout title="奖品领取">
  4. <view class="ss-flex" style="justify-content: flex-end;">
  5. <button class="refresh-btn ss-reset-button" type="warn" plain="true" @tap.stop="getAddressList">
  6. <uni-icons type="reload" color="#ff3404" size="30"></uni-icons>
  7. 刷 新
  8. </button>
  9. </view>
  10. <view v-if="state.addressList.length">
  11. <view class="address-item ss-flex ss-row-between ss-col-center border-bottom"
  12. v-for="(item, index) in state.addressList"
  13. :key="item.id"
  14. @tap.stop="state.selectedIndex = index"
  15. >
  16. <view class="item-left">
  17. <view class="area-text ss-flex ss-col-center">{{ item.areaName }}</view>
  18. <view class="address-text">{{ item.detailAddress }}</view>
  19. <view class="person-text"> {{ item.name }} {{ item.mobile }} </view>
  20. </view>
  21. <view>
  22. <uni-icons
  23. :type="index === state.selectedIndex ? 'checkbox-filled' : 'circle'"
  24. :color="index === state.selectedIndex ? '#ff3404' : '#000000'"
  25. size="28"
  26. ></uni-icons>
  27. </view>
  28. </view>
  29. </view>
  30. <su-fixed bottom :opacity="false" bg="" placeholder :noFixed="false" :index="10">
  31. <view class="footer-box ss-flex-col ss-row-between">
  32. <view class="ss-m-b-20 ss-flex">
  33. <button
  34. class="save-btn ss-reset-button ui-Shadow-Main"
  35. @tap="sheep.$router.go('/pages/user/address/edit')"
  36. >
  37. 新增收货地址
  38. </button>
  39. <button class="ss-reset-button save-btn ui-Shadow-Main" @tap.stop="onSave">领取</button>
  40. </view>
  41. </view>
  42. </su-fixed>
  43. </s-layout>
  44. </template>
  45. <script setup>
  46. import { ref, reactive } from 'vue';
  47. import sheep from '@/sheep';
  48. import { onLoad, onShow } from '@dcloudio/uni-app';
  49. import _ from 'lodash-es';
  50. import AddressApi from '@/sheep/api/member/address';
  51. import PrizeApi from '@/sheep/api/prizeDraw'
  52. const state = reactive({
  53. selectedIndex: 0,
  54. addressList: [],
  55. });
  56. // 获取收货地址
  57. const getAddressList = async () => {
  58. const list = (await AddressApi.getAddressList()).data;
  59. state.addressList = list.map(e => {
  60. return { text: e.areaName, value: e.id, ...e }
  61. })
  62. }
  63. // 保存收货地址
  64. const onSave = async () => {
  65. if (!state.addressList || !state.addressList.length) {
  66. uni.showToast({
  67. title: '请新增收货地址',
  68. icon: 'none',
  69. duration: 2000
  70. })
  71. return
  72. }
  73. const address = state.addressList[state.selectedIndex]
  74. if (!address || !Object.keys(address).length) {
  75. uni.showToast({
  76. title: '请选择收货地址',
  77. icon: 'none',
  78. duration: 2000
  79. })
  80. return
  81. }
  82. const { code } = await PrizeApi.luckyLotteryRecordReceive({ id: receiveId.value, receiveInfo: JSON.stringify(address) })
  83. if (code === 0) {
  84. sheep.$router.back();
  85. }
  86. }
  87. const receiveId = ref()
  88. onLoad(async (options) => {
  89. receiveId.value = options.id
  90. })
  91. onShow(async () => {
  92. // 获取收货地址列表
  93. await getAddressList()
  94. })
  95. </script>
  96. <style lang="scss">
  97. .address-item {
  98. padding: 24rpx 30rpx;
  99. .item-left {
  100. width: 600rpx;
  101. }
  102. .area-text {
  103. font-size: 26rpx;
  104. font-weight: 400;
  105. color: $dark-9;
  106. }
  107. .address-text {
  108. font-size: 32rpx;
  109. font-weight: 500;
  110. color: #333333;
  111. line-height: 48rpx;
  112. }
  113. .person-text {
  114. font-size: 28rpx;
  115. font-weight: 400;
  116. color: $dark-9;
  117. }
  118. }
  119. :deep() {
  120. .uni-forms-item__label .label-text {
  121. font-size: 28rpx !important;
  122. color: #333333 !important;
  123. line-height: normal !important;
  124. }
  125. .uni-easyinput__content-input {
  126. font-size: 28rpx !important;
  127. color: #333333 !important;
  128. line-height: normal !important;
  129. padding-left: 0 !important;
  130. }
  131. .uni-easyinput__content-textarea {
  132. font-size: 28rpx !important;
  133. color: #333333 !important;
  134. line-height: normal !important;
  135. margin-top: 8rpx !important;
  136. }
  137. .uni-icons {
  138. font-size: 40rpx !important;
  139. }
  140. .is-textarea-icon {
  141. margin-top: 22rpx;
  142. }
  143. .is-disabled {
  144. color: #333333;
  145. }
  146. .uni-data-checklist .checklist-group {
  147. display: block !important;
  148. }
  149. }
  150. .default-box {
  151. width: 100%;
  152. box-sizing: border-box;
  153. height: 100rpx;
  154. .default-box-title {
  155. font-size: 28rpx;
  156. color: #333333;
  157. line-height: normal;
  158. }
  159. }
  160. .refresh-btn {
  161. width: 200rpx;
  162. height: 80rpx;
  163. border-radius: 40rpx;
  164. }
  165. .footer-box {
  166. width: 100vw;
  167. .save-btn {
  168. width: 100%;
  169. height: 80rpx;
  170. border-radius: 40rpx;
  171. background: linear-gradient(90deg, var(--ui-BG-Main), var(--ui-BG-Main-gradient));
  172. color: $white;
  173. margin: 0 20rpx;
  174. }
  175. }
  176. </style>