receipt.vue 8.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352
  1. <template>
  2. <view>
  3. <view class="order_info">
  4. <view class="order_title">
  5. <view class="business_name">{{ orderInfo.business_name }}</view>
  6. </view>
  7. <view class="product_list">
  8. <view class="product_item" v-for="(product_info, k) in orderInfo.product_list" :key="k">
  9. <image class="product_img" :src="product_info.product_thumb" mode=""></image>
  10. <view class="product_info">
  11. <view class="product_name"> <text v-if="product_info.is_rebate">【赠】</text> {{ product_info.product_name }} </view>
  12. <view class="product_spec">
  13. {{ product_info.product_spec }}
  14. </view>
  15. </view>
  16. <view class="buy_num"> x{{ product_info.buy_num }} </view>
  17. </view>
  18. </view>
  19. </view>
  20. <view class="upload_box">
  21. <view class="image_box" @click="chooseImage()">
  22. <image class="upload_image" :src="localImage" v-if="localImage"></image>
  23. <text class="upload_text" v-if="!localImage">请点此处上传图片</text>
  24. </view>
  25. </view>
  26. <view class="info_alter">
  27. <view class=""> 请谨慎上传回执,上传后无法修改 </view>
  28. <view class=""> 上传后有机会获得积分 </view>
  29. </view>
  30. <view class="btn_box">
  31. <button class="upload_btn" v-if="localImage" @click="toApply()">提交</button>
  32. <button class="upload_btn disable" v-if="!localImage">提交</button>
  33. </view>
  34. <uni-popup ref="sharePopup" type="center" :mask-click="false">
  35. <view class="share_info">
  36. <view class="state_icon">
  37. <uni-icons type="checkbox" color="#07C160"></uni-icons>
  38. </view>
  39. <view class="state_text">图片上传成功</view>
  40. <button class="share_btn" open-type="share">
  41. <uni-icons type="weixin" color="#FFFFFF"></uni-icons>
  42. <text>立即分享到微信群</text>
  43. </button>
  44. <view class="info_text">工作人员审核通过后将发放积分</view>
  45. </view>
  46. </uni-popup>
  47. </view>
  48. </template>
  49. <script>
  50. export default {
  51. data() {
  52. return {
  53. order_id: 0,
  54. localImage: "",
  55. orderInfo: {},
  56. shareInfo: {
  57. title: "我已经完成一笔订单,你也快来吧",
  58. path: "/pages/index/index",
  59. imageUrl: "",
  60. },
  61. };
  62. },
  63. onLoad(param) {
  64. this.order_id = param.order_id;
  65. },
  66. onShow() {
  67. // 登录提示
  68. if (!this.$checkAccess.alterLogin()) return;
  69. // 判断订单ID
  70. if (this.order_id <= 0) {
  71. uni.showModal({
  72. content: "未知的活动ID",
  73. showCancel: false,
  74. });
  75. return;
  76. }
  77. // 没有数据的话,或者请求中,不允许刷新
  78. if (this.isReqing) return;
  79. // 设置请求中
  80. this.isReqing = true;
  81. // 请求列表
  82. this.$http.request("api/orders/get_item", { id: this.order_id }).then((re) => {
  83. // 设置非请求中
  84. this.isReqing = false;
  85. // 成功结果
  86. if (re.code == "success") {
  87. this.orderInfo = re.data;
  88. } else {
  89. if (re.code != "no_login") {
  90. uni.showModal({
  91. content: re.msg,
  92. showCancel: false,
  93. });
  94. }
  95. }
  96. });
  97. },
  98. onShareAppMessage(obj) {
  99. return this.shareInfo;
  100. },
  101. methods: {
  102. chooseImage() {
  103. uni.chooseImage({
  104. count: 1, // 默认9,设置图片的数量
  105. sizeType: ["compressed"], // 可以指定是原图还是压缩图,默认二者都有
  106. sourceType: ["album", "camera"], // 可以指定来源是相册还是相机,默认二者都有
  107. success: (chooseImageRes) => {
  108. let tempFilePaths = chooseImageRes.tempFilePaths;
  109. this.localImage = tempFilePaths[0];
  110. },
  111. });
  112. },
  113. toApply() {
  114. // 判断订单ID
  115. if (this.order_id <= 0) {
  116. uni.showModal({
  117. content: "未知的活动ID",
  118. showCancel: false,
  119. });
  120. return;
  121. }
  122. // 判断订单ID
  123. if (!this.localImage) {
  124. uni.showModal({
  125. content: "请上传图片",
  126. showCancel: false,
  127. });
  128. return;
  129. }
  130. // 没有数据的话,或者请求中,不允许刷新
  131. if (this.isReqing) return;
  132. // 请求中
  133. uni.showLoading();
  134. // 设置请求中
  135. this.isReqing = true;
  136. // 请求列表
  137. this.$http.fileupload("api/orders_receipt/apply", this.localImage, { order_id: this.order_id }).then((re) => {
  138. // 设置非请求中
  139. uni.hideLoading();
  140. // 成功结果
  141. if (re.code == "success") {
  142. // 赋值
  143. this.shareInfo = re.data.share_info;
  144. // 弹出提示
  145. this.$refs.sharePopup.open("center");
  146. } else {
  147. if (re.code != "no_login") {
  148. // 设置请求中
  149. this.isReqing = false;
  150. // 允许请求
  151. uni.showModal({
  152. content: re.msg,
  153. showCancel: false,
  154. });
  155. }
  156. }
  157. });
  158. },
  159. },
  160. };
  161. </script>
  162. <style lang="less">
  163. .order_info {
  164. display: block;
  165. background: #ffffff;
  166. margin: 0rpx auto;
  167. padding: 0rpx 35rpx;
  168. margin-bottom: 10rpx;
  169. .order_title {
  170. width: 100%;
  171. height: 60rpx;
  172. display: block;
  173. overflow: hidden;
  174. line-height: 60rpx;
  175. .business_name {
  176. float: left;
  177. font-size: 32rpx;
  178. display: flex;
  179. align-items: center;
  180. .business_icon {
  181. width: 48rpx;
  182. height: 48rpx;
  183. margin-right: 10rpx;
  184. }
  185. }
  186. .order_status {
  187. float: right;
  188. color: #999999;
  189. font-size: 24rpx;
  190. }
  191. }
  192. .product_list {
  193. display: block;
  194. overflow: hidden;
  195. margin: 15rpx auto;
  196. .product_item {
  197. display: block;
  198. height: 100rpx;
  199. overflow: hidden;
  200. .product_img {
  201. float: left;
  202. width: 80rpx;
  203. height: 80rpx;
  204. display: block;
  205. margin-top: 10rpx;
  206. margin-right: 30rpx;
  207. }
  208. .product_info {
  209. float: left;
  210. width: 480rpx;
  211. height: 100rpx;
  212. display: block;
  213. overflow: hidden;
  214. .product_name {
  215. display: block;
  216. height: 60rpx;
  217. display: block;
  218. font-size: 28rpx;
  219. line-height: 60rpx;
  220. overflow: hidden;
  221. }
  222. .product_spec {
  223. color: #999999;
  224. height: 40rpx;
  225. display: block;
  226. font-size: 24rpx;
  227. line-height: 40rpx;
  228. overflow: hidden;
  229. }
  230. }
  231. .buy_num {
  232. float: right;
  233. height: 100rpx;
  234. color: #999999;
  235. font-size: 26rpx;
  236. text-align: right;
  237. position: relative;
  238. line-height: 100rpx;
  239. }
  240. }
  241. }
  242. .product_list.active {
  243. height: auto !important;
  244. }
  245. }
  246. .upload_box {
  247. display: block;
  248. width: 750rpx;
  249. height: 410rpx;
  250. margin-top: 20rpx;
  251. text-align: center;
  252. padding: 20rpx 0rpx;
  253. background-color: #ffffff;
  254. .image_box {
  255. width: 400rpx;
  256. height: 400rpx;
  257. display: block;
  258. color: #999999;
  259. font-size: 28rpx;
  260. margin: 0rpx auto;
  261. line-height: 400rpx;
  262. border: 2rpx solid #999999;
  263. .upload_image {
  264. width: 400rpx;
  265. height: 400rpx;
  266. }
  267. }
  268. }
  269. .info_alter {
  270. // color: #E03519;
  271. display: block;
  272. font-size: 26rpx;
  273. overflow: hidden;
  274. line-height: 60rpx;
  275. text-align: center;
  276. margin: 0rpx auto;
  277. background-color: #ffffff;
  278. }
  279. .btn_box {
  280. display: block;
  281. overflow: hidden;
  282. margin: 20rpx auto;
  283. .upload_btn {
  284. color: #ffffff;
  285. display: block;
  286. width: 680rpx;
  287. height: 80rpx;
  288. margin: 0 auto;
  289. font-size: 28rpx;
  290. line-height: 80rpx;
  291. padding: 0rpx 0rpx;
  292. border-radius: 10rpx;
  293. background-color: #07c160;
  294. }
  295. .upload_btn.disable {
  296. background-color: #999999;
  297. }
  298. .upload_btn::after {
  299. border: none;
  300. }
  301. }
  302. .share_info {
  303. width: 600rpx;
  304. height: 600rpx;
  305. background-color: #ffffff;
  306. .state_icon {
  307. width: 240rpx;
  308. height: 240rpx;
  309. display: block;
  310. margin: 20rpx auto;
  311. text-align: center;
  312. font-size: 240rpx !important;
  313. .uni-icons {
  314. font-size: 240rpx !important;
  315. }
  316. }
  317. .state_text {
  318. height: 80rpx;
  319. display: block;
  320. font-size: 32rpx;
  321. margin: 20rpx auto;
  322. line-height: 80rpx;
  323. text-align: center;
  324. }
  325. .share_btn {
  326. color: #ffffff;
  327. display: block;
  328. width: 560rpx;
  329. height: 80rpx;
  330. font-size: 30rpx;
  331. margin: 20rpx auto;
  332. line-height: 80rpx;
  333. padding: 0rpx 0rpx;
  334. border-radius: 10rpx;
  335. background-color: #07c160;
  336. .uni-icons {
  337. margin-right: 20rpx;
  338. font-size: 36rpx !important;
  339. }
  340. }
  341. .info_text {
  342. height: 60rpx;
  343. display: block;
  344. font-size: 26rpx;
  345. margin-top: 20rpx;
  346. line-height: 60rpx;
  347. text-align: center;
  348. }
  349. }
  350. </style>