uploadReceptPopop.vue 4.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  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. return uni.showToast({
  70. title: "请先选择优惠力度",
  71. icon: "error",
  72. });
  73. const params = {
  74. openid,
  75. marketingActivityId: props.id,
  76. discountId: discountId.value,
  77. };
  78. validate(params)
  79. .then((res: any) => {
  80. if (res.valid) {
  81. uni.navigateTo({
  82. url: `/pagesOne/winner/uploadImage?discountId=${discountId.value}&discountLevel=${discountLevel.value}`,
  83. });
  84. return;
  85. }
  86. uni.showToast({
  87. title: "该活动力度次数您已经用完啦,换一个活动力度参与吧",
  88. icon: "none",
  89. });
  90. return;
  91. })
  92. .catch((err) => {
  93. uni.showToast({
  94. title: err.msg,
  95. icon: "none",
  96. });
  97. });
  98. emit("update:show", false);
  99. };
  100. const discountId = ref<string>("");
  101. const discountLevel = ref<string>("");
  102. const radioChange = (e: any) => {
  103. discountId.value = e.detail.value;
  104. const obj = props.list!.filter((item) => item.id === e.detail.value)[0];
  105. discountLevel.value = `满${obj.thresholdAmount}返${obj.cashbackAmount}`;
  106. };
  107. const { handleClose } = useDraw(props, emit);
  108. </script>
  109. <style lang="scss">
  110. .uploadReceptPopup {
  111. .topTitle {
  112. font-size: 36rpx;
  113. color: #1f1f39;
  114. height: 80rpx;
  115. text-align: center;
  116. margin-top: 26rpx;
  117. .tips {
  118. font-size: 20rpx;
  119. color: #bfc8db;
  120. }
  121. }
  122. .receptBox {
  123. max-height: 350rpx;
  124. overflow-y: scroll;
  125. }
  126. .radioItem {
  127. display: flex;
  128. justify-content: space-between;
  129. align-items: center;
  130. padding: 0 60rpx;
  131. height: 80rpx;
  132. box-sizing: border-box;
  133. color: #333;
  134. font-size: 32rpx;
  135. .left {
  136. display: flex;
  137. align-items: center;
  138. }
  139. .icon {
  140. width: 36rpx;
  141. height: 36rpx;
  142. margin-right: 20rpx;
  143. }
  144. &.active {
  145. background-color: #f7f8f9;
  146. }
  147. &.static {
  148. background-color: #fff;
  149. }
  150. }
  151. .radioItem:focus {
  152. background-color: pink;
  153. }
  154. .btnBox {
  155. font-size: 36rpx;
  156. color: #555d6c;
  157. margin-top: 48rpx;
  158. > view {
  159. text-align: center;
  160. width: 100%;
  161. line-height: 108rpx;
  162. }
  163. .play {
  164. background: #f7f8f9;
  165. }
  166. }
  167. }
  168. </style>