uploadReceptPopop.vue 4.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183
  1. <template>
  2. <view 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 props.list"
  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. />
  34. </label>
  35. </radio-group>
  36. <view class="btnBox">
  37. <view class="play" @click="toUploadImage">去上传图片</view>
  38. <!-- <view class="phone" @click="toUploadImage('album')"
  39. >从手机相册选择</view
  40. > -->
  41. <wd-gap height="16rpx" bg-color="#F7F8F9"></wd-gap>
  42. <view @click="handleClose">取消</view>
  43. </view>
  44. </wd-popup>
  45. </view>
  46. </template>
  47. <script lang="ts" setup>
  48. import { reactive, ref } from "vue";
  49. import { imgObj } from "../utils/source";
  50. import { useDraw } from "@/hooks/useDraw";
  51. import { receptProp } from "../utils/interface";
  52. import { validate } from "@/services/ams";
  53. const props = defineProps({
  54. show: {
  55. type: Boolean,
  56. default: false,
  57. },
  58. id: {
  59. type: String,
  60. defalut: "",
  61. },
  62. list: Array<receptProp>,
  63. });
  64. const openid = uni.getStorageSync("openid");
  65. const emit = defineEmits(["update:show"]);
  66. const value = ref("1");
  67. const toUploadImage = (type: string) => {
  68. if (!discountId.value) {
  69. uni.showToast({
  70. title: "请先选择优惠力度",
  71. icon: "error",
  72. });
  73. return;
  74. }
  75. const params = {
  76. openid,
  77. marketingActivityId: props.id,
  78. discountId: discountId.value,
  79. };
  80. validate(params)
  81. .then((res: any) => {
  82. if (res.valid) {
  83. uni.navigateTo({
  84. url: `/pagesOne/winner/uploadImage?discountId=${discountId.value}&discountLevel=${discountLevel.value}`,
  85. });
  86. return;
  87. }
  88. uni.showModal({
  89. title: "提示",
  90. content: res.message,
  91. showCancel: false, // 如果只需要确定按钮,可以隐藏取消按钮
  92. });
  93. // uni.showToast({
  94. // title: res.message || "",
  95. // icon: "none",
  96. // });
  97. })
  98. .catch((err) => {
  99. uni.showToast({
  100. title: err.msg,
  101. icon: "none",
  102. });
  103. });
  104. emit("update:show", false);
  105. };
  106. const discountId = ref<string>("");
  107. const discountLevel = ref<string>("");
  108. const radioChange = (e: any) => {
  109. discountId.value = e.detail.value;
  110. const obj = props.list!.filter((item) => item.id === e.detail.value)[0];
  111. discountLevel.value = `满${obj.thresholdAmount}返${obj.cashbackAmount}`;
  112. };
  113. const { handleClose } = useDraw(props, emit);
  114. </script>
  115. <style lang="scss">
  116. .uploadReceptPopup {
  117. .topTitle {
  118. font-size: 36rpx;
  119. color: #1f1f39;
  120. height: 80rpx;
  121. text-align: center;
  122. margin-top: 26rpx;
  123. .tips {
  124. font-size: 20rpx;
  125. color: #bfc8db;
  126. }
  127. }
  128. .receptBox {
  129. max-height: 350rpx;
  130. overflow-y: scroll;
  131. }
  132. .radioItem {
  133. display: flex;
  134. justify-content: space-between;
  135. align-items: center;
  136. padding: 0 60rpx;
  137. height: 80rpx;
  138. box-sizing: border-box;
  139. color: #333;
  140. font-size: 32rpx;
  141. .left {
  142. display: flex;
  143. align-items: center;
  144. }
  145. .icon {
  146. width: 36rpx;
  147. height: 36rpx;
  148. margin-right: 20rpx;
  149. }
  150. &.active {
  151. background-color: #f7f8f9;
  152. }
  153. &.static {
  154. background-color: #fff;
  155. }
  156. }
  157. .radioItem:focus {
  158. background-color: pink;
  159. }
  160. .btnBox {
  161. font-size: 36rpx;
  162. color: #555d6c;
  163. margin-top: 48rpx;
  164. > view {
  165. text-align: center;
  166. width: 100%;
  167. line-height: 108rpx;
  168. }
  169. .play {
  170. background: #f7f8f9;
  171. }
  172. }
  173. }
  174. </style>