uploadReceptPopop.vue 4.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209
  1. <template>
  2. <view v-if="props.show" class="uploadReceptPopup">
  3. <wd-popup
  4. v-model="props.show"
  5. position="bottom"
  6. :safe-area-inset-bottom="true"
  7. custom-style="max-height: 922rpx;border-radius: 40rpx 40rpx 0 0;"
  8. @close="handleClose"
  9. >
  10. <view class="topTitle">
  11. <text>上传小票</text>
  12. <text class="tips">(*先选择优惠力度再上传)</text>
  13. </view>
  14. <radio-group class="receptBox" @change="radioChange">
  15. <label
  16. v-for="item in receptList"
  17. :key="item.id"
  18. class="radioItem"
  19. :class="item.checked ? 'active' : 'static'"
  20. >
  21. <view class="left">
  22. <image class="icon" :src="imgObj.icon1" mode="scaleToFill" />
  23. <text class="label"
  24. >满{{ item.thresholdAmount }}返{{ item.cashbackAmount }}</text
  25. >
  26. </view>
  27. <radio
  28. class="radio"
  29. color="#225036"
  30. :value="item.id"
  31. style="transform: scale(0.9)"
  32. :checked="item.checked"
  33. :disabled="item.disabled"
  34. />
  35. </label>
  36. </radio-group>
  37. <view class="btnBox">
  38. <view class="play" @click="toUploadImage">去上传图片</view>
  39. <!-- <view class="phone" @click="toUploadImage('album')"
  40. >从手机相册选择</view
  41. > -->
  42. <wd-gap height="16rpx" bg-color="#F7F8F9"></wd-gap>
  43. <view @click="handleClose">取消</view>
  44. </view>
  45. </wd-popup>
  46. </view>
  47. </template>
  48. <script lang="ts" setup>
  49. import { reactive, ref, watch } from "vue";
  50. import { imgObj } from "../utils/source";
  51. import { useDraw } from "@/hooks/useDraw";
  52. import type { Receipt } from "@/services/interface";
  53. import { validate } from "@/services/ams";
  54. const props = defineProps({
  55. show: {
  56. type: Boolean,
  57. default: false,
  58. },
  59. id: {
  60. type: String,
  61. defalut: "",
  62. },
  63. list: Array<Receipt>,
  64. });
  65. const openid = uni.getStorageSync("openid");
  66. const emit = defineEmits(["update:show"]);
  67. const value = ref("1");
  68. let receptList: any = ref([]);
  69. watch(
  70. () => props.list,
  71. (newVal) => {
  72. receptList.value = newVal;
  73. },
  74. { deep: true, immediate: true }
  75. );
  76. watch(
  77. () => props.show,
  78. (newVal) => {
  79. if (newVal) {
  80. discountId.value = "";
  81. }
  82. }
  83. );
  84. const toUploadImage = (type: string) => {
  85. if (!discountId.value) {
  86. uni.showToast({
  87. title: "请先选择优惠力度",
  88. icon: "error",
  89. });
  90. return;
  91. }
  92. const params = {
  93. openid,
  94. marketingActivityId: props.id,
  95. discountId: discountId.value,
  96. };
  97. validate(params)
  98. .then((res: any) => {
  99. if (res.valid) {
  100. uni.navigateTo({
  101. url: `/pagesOne/winner/uploadImage?discountId=${discountId.value}&discountLevel=${discountLevel.value}`,
  102. });
  103. return;
  104. } else {
  105. uni.showModal({
  106. title: "提示",
  107. content: res.message || "",
  108. showCancel: false, // 如果只需要确定按钮,可以隐藏取消按钮
  109. });
  110. for (let i of receptList.value) {
  111. if (i.id === discountId.value) {
  112. i.disabled = true;
  113. }
  114. }
  115. }
  116. })
  117. .catch((err) => {
  118. uni.showModal({
  119. title: "提示",
  120. content: err.message || "网络异常,请稍后再试",
  121. showCancel: false,
  122. });
  123. });
  124. emit("update:show", false);
  125. };
  126. const discountId = ref<string>("");
  127. const discountLevel = ref<string>("");
  128. const radioChange = (e: any) => {
  129. discountId.value = e.detail.value;
  130. const obj = receptList.value.filter(
  131. (item: any) => item.id === e.detail.value
  132. )[0];
  133. discountLevel.value = `满${obj.thresholdAmount}返${obj.cashbackAmount}`;
  134. };
  135. const { handleClose } = useDraw(props, emit);
  136. </script>
  137. <style lang="scss">
  138. .uploadReceptPopup {
  139. .topTitle {
  140. font-size: 36rpx;
  141. color: #1f1f39;
  142. height: 80rpx;
  143. text-align: center;
  144. margin-top: 26rpx;
  145. .tips {
  146. font-size: 20rpx;
  147. color: #bfc8db;
  148. }
  149. }
  150. .receptBox {
  151. max-height: 350rpx;
  152. overflow-y: scroll;
  153. }
  154. .radioItem {
  155. display: flex;
  156. justify-content: space-between;
  157. align-items: center;
  158. padding: 0 60rpx;
  159. height: 80rpx;
  160. box-sizing: border-box;
  161. color: #333;
  162. font-size: 32rpx;
  163. .left {
  164. display: flex;
  165. align-items: center;
  166. }
  167. .icon {
  168. width: 36rpx;
  169. height: 36rpx;
  170. margin-right: 20rpx;
  171. }
  172. &.active {
  173. background-color: #f7f8f9;
  174. }
  175. &.static {
  176. background-color: #fff;
  177. }
  178. }
  179. .radioItem:focus {
  180. background-color: pink;
  181. }
  182. .btnBox {
  183. font-size: 36rpx;
  184. color: #555d6c;
  185. margin-top: 48rpx;
  186. > view {
  187. text-align: center;
  188. width: 100%;
  189. line-height: 108rpx;
  190. }
  191. .play {
  192. background: #f7f8f9;
  193. }
  194. }
  195. }
  196. </style>