receipt.vue 8.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345
  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. }
  179. .order_status {
  180. float: right;
  181. color: #999999;
  182. font-size: 24rpx;
  183. }
  184. }
  185. .product_list {
  186. display: block;
  187. overflow: hidden;
  188. margin: 15rpx auto;
  189. .product_item {
  190. display: block;
  191. height: 100rpx;
  192. overflow: hidden;
  193. .product_img {
  194. float: left;
  195. width: 80rpx;
  196. height: 80rpx;
  197. display: block;
  198. margin-top: 10rpx;
  199. margin-right: 30rpx;
  200. }
  201. .product_info {
  202. float: left;
  203. width: 480rpx;
  204. height: 100rpx;
  205. display: block;
  206. overflow: hidden;
  207. .product_name {
  208. display: block;
  209. height: 60rpx;
  210. display: block;
  211. font-size: 28rpx;
  212. line-height: 60rpx;
  213. overflow: hidden;
  214. }
  215. .product_spec {
  216. color: #999999;
  217. height: 40rpx;
  218. display: block;
  219. font-size: 24rpx;
  220. line-height: 40rpx;
  221. overflow: hidden;
  222. }
  223. }
  224. .buy_num {
  225. float: right;
  226. height: 100rpx;
  227. color: #999999;
  228. font-size: 26rpx;
  229. text-align: right;
  230. position: relative;
  231. line-height: 100rpx;
  232. }
  233. }
  234. }
  235. .product_list.active {
  236. height: auto !important;
  237. }
  238. }
  239. .upload_box {
  240. display: block;
  241. width: 750rpx;
  242. height: 410rpx;
  243. margin-top: 20rpx;
  244. text-align: center;
  245. padding: 20rpx 0rpx;
  246. background-color: #ffffff;
  247. .image_box {
  248. width: 400rpx;
  249. height: 400rpx;
  250. display: block;
  251. color: #999999;
  252. font-size: 28rpx;
  253. margin: 0rpx auto;
  254. line-height: 400rpx;
  255. border: 2rpx solid #999999;
  256. .upload_image {
  257. width: 400rpx;
  258. height: 400rpx;
  259. }
  260. }
  261. }
  262. .info_alter {
  263. // color: #E03519;
  264. display: block;
  265. font-size: 26rpx;
  266. overflow: hidden;
  267. line-height: 60rpx;
  268. text-align: center;
  269. margin: 0rpx auto;
  270. background-color: #ffffff;
  271. }
  272. .btn_box {
  273. display: block;
  274. overflow: hidden;
  275. margin: 20rpx auto;
  276. .upload_btn {
  277. color: #ffffff;
  278. display: block;
  279. width: 680rpx;
  280. height: 80rpx;
  281. margin: 0 auto;
  282. font-size: 28rpx;
  283. line-height: 80rpx;
  284. padding: 0rpx 0rpx;
  285. border-radius: 10rpx;
  286. background-color: #07c160;
  287. }
  288. .upload_btn.disable {
  289. background-color: #999999;
  290. }
  291. .upload_btn::after {
  292. border: none;
  293. }
  294. }
  295. .share_info {
  296. width: 600rpx;
  297. height: 600rpx;
  298. background-color: #ffffff;
  299. .state_icon {
  300. width: 240rpx;
  301. height: 240rpx;
  302. display: block;
  303. margin: 20rpx auto;
  304. text-align: center;
  305. font-size: 240rpx !important;
  306. .uni-icons {
  307. font-size: 240rpx !important;
  308. }
  309. }
  310. .state_text {
  311. height: 80rpx;
  312. display: block;
  313. font-size: 32rpx;
  314. margin: 20rpx auto;
  315. line-height: 80rpx;
  316. text-align: center;
  317. }
  318. .share_btn {
  319. color: #ffffff;
  320. display: block;
  321. width: 560rpx;
  322. height: 80rpx;
  323. font-size: 30rpx;
  324. margin: 20rpx auto;
  325. line-height: 80rpx;
  326. padding: 0rpx 0rpx;
  327. border-radius: 10rpx;
  328. background-color: #07c160;
  329. .uni-icons {
  330. margin-right: 20rpx;
  331. font-size: 36rpx !important;
  332. }
  333. }
  334. .info_text {
  335. height: 60rpx;
  336. display: block;
  337. font-size: 26rpx;
  338. margin-top: 20rpx;
  339. line-height: 60rpx;
  340. text-align: center;
  341. }
  342. }
  343. </style>