waitOrderDetail.vue 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433
  1. <template>
  2. <view class="order-pages">
  3. <view class="order-info">
  4. <!-- 订单状态 -->
  5. <view class="order-status">
  6. <view class="status-title flex align_center justify_center">
  7. <u-icon class="icon" name="icon_service"
  8. custom-prefix="custom-icon" size="48" color="#333333"></u-icon>
  9. {{orderInfo.orderStatusDictValue}}
  10. </view>
  11. <view class="status-care">
  12. 预约时间:{{orderInfo.reserveTime}}
  13. </view>
  14. </view>
  15. <!-- 回收品类明细 -->
  16. <view class="item-info">
  17. <view class="item-title">
  18. <view>回收品类明细</view>
  19. <view class="care">(切换分类可输入不同回收物的价格和重量)</view>
  20. </view>
  21. <view class="item flex">
  22. <view :class="['item-type', curType == item.code ? 'active' : '']" v-for="(item,index) in typeData" :key="item.id" @click="getRow(item.code,index)">
  23. {{item.dispName}}
  24. </view>
  25. </view>
  26. <view class="table">
  27. <view>单价(元/kg)</view>
  28. <view>重量(kg)</view>
  29. <view>合计金额(元)</view>
  30. </view>
  31. <view v-if="list.length && list[curIndex].typeList.length" v-for="item in list[curIndex].typeList" :key="item.id" class="item flex justify_between align_center">
  32. <view class="flex align_center">
  33. <text>{{item.name}}</text>
  34. <u-input :custom-style="inputLeftStyle" input-align="center" :clearable="false" v-model="item.customerPrice" placeholder="" type="number" />
  35. </view>
  36. <view class="flex flex_1 align_center">
  37. <u-input input-align="center" :clearable="false" v-model="item.rubbishWeight" placeholder="请输入重量" type="number" />
  38. </view>
  39. <view class="flex_1 flex align_center justify_center">{{item.customerPrice*item.rubbishWeight}}</view>
  40. </view>
  41. </view>
  42. <!-- 金额 -->
  43. <view class="item-info">
  44. <view class="item flex justify_between">
  45. <text>应付金额</text>
  46. <text>{{originalAmount}} 元</text>
  47. </view>
  48. <view class="item flex justify_between">
  49. <text>支付方式</text>
  50. <v-select class="flex_1" ref="payType" placeholder="请选择支付方式" @itemChange="chooseType" code="ORDER_RESERVE_PAY_TYPE" style="width: 100%"></v-select>
  51. </view>
  52. </view>
  53. <!-- 服务信息 -->
  54. <view class="info-main flex flex_column">
  55. <view class="flex flex_1 align_center">
  56. <view class="new-left ellipsis-two">
  57. {{orderInfo.contactAddress}}
  58. </view>
  59. </view>
  60. <view class="time flex align_center justify_between">
  61. <text>{{orderInfo.contactName}}</text>
  62. <view class="flex align_center">
  63. <u-icon class="phone" name="icon_phone" custom-prefix="custom-icon" size="28" color="#999999"></u-icon>
  64. <text>{{orderInfo.contactMobile}}</text>
  65. </view>
  66. </view>
  67. </view>
  68. </view>
  69. <view class="footer">
  70. <u-button @click="submit" :loading="loading" class="flex_1" type="primary">提交</u-button>
  71. </view>
  72. </view>
  73. </template>
  74. <script>
  75. import moment from 'moment'
  76. import { orderDetailFind, orderSubmit } from '@/api/order.js'
  77. import { getLookUpDatas } from '@/api/data.js'
  78. import { reservePriceFind } from '@/api/index.js'
  79. import vSelect from '@/components/select/v-select.vue'
  80. export default {
  81. components: {
  82. vSelect
  83. },
  84. data() {
  85. return {
  86. orderInfo: {},
  87. totalPrice: 0, // 支付合计
  88. orderReserveNo: '', // 订单号
  89. inputLeftStyle: {
  90. Width: '120rpx',
  91. borderBottom: '1px solid #707070',
  92. padding: '0rpx 10rpx',
  93. color: '#191919'
  94. },
  95. curType: '', // 当前类型
  96. curIndex: 0, // 当前类型index
  97. typeData: [], // 垃圾类型数据
  98. list: [],
  99. payType: '', // 支付方式
  100. loading: false
  101. }
  102. },
  103. onLoad(options) {
  104. if (options.orderNo) {
  105. console.log(options.orderNo)
  106. this.orderReserveNo = options.orderNo
  107. this.getOrderDetail()
  108. this.getRubbishType()
  109. }
  110. // 开启分享
  111. uni.showShareMenu({
  112. withShareTicket: true,
  113. menus: ['shareAppMessage', 'shareTimeline']
  114. })
  115. },
  116. computed: {
  117. // 支付总金额
  118. originalAmount() {
  119. let total = 0
  120. if(this.list.length){
  121. this.list.map(item =>{
  122. item.typeList.map(k =>{
  123. total = total + (k.customerPrice*k.rubbishWeight)
  124. })
  125. })
  126. }
  127. return total
  128. },
  129. // 总重量
  130. totalWeight() {
  131. let total = 0
  132. if(this.list.length){
  133. this.list.map(item =>{
  134. item.typeList.map(k =>{
  135. total = total + k.rubbishWeight
  136. })
  137. })
  138. }
  139. return total
  140. }
  141. },
  142. methods: {
  143. // 小数点后两位
  144. numberToFixed: function (item,key, num) {
  145. let val = item[key]
  146. let ret = numberToFixed(val, num, 999999)
  147. this.$nextTick(() => {
  148. item[key] = Number(ret)
  149. })
  150. },
  151. // 获取订单详情
  152. getOrderDetail() {
  153. uni.showLoading({
  154. title: '加载中...'
  155. })
  156. orderDetailFind({
  157. orderReserveNo: this.orderReserveNo
  158. }).then(res => {
  159. console.log(res,'rrrrrrrr')
  160. if (res.status == 200) {
  161. this.orderInfo = res.data
  162. this.orderInfo.reserveTime = moment(this.orderInfo.confirmDate).format('YYYY-MM-DD') + this.orderInfo.reserveTimeTypeDictValue
  163. }
  164. uni.hideLoading()
  165. })
  166. },
  167. // 获取垃圾类型数据
  168. getRubbishType() {
  169. this.list = []
  170. getLookUpDatas({type:'RESERVE_RUBBISH_TYPE'}).then(res=>{
  171. console.log(res,'------rrrrrr')
  172. if(res.status == 200) {
  173. this.typeData = res.data || []
  174. this.typeData.map(k =>{
  175. let p = {
  176. typeCode: k.code,
  177. typeList: []
  178. }
  179. console.log(p,'pppppp')
  180. this.list.push(p)
  181. })
  182. console.log(this.list,'this.list----------')
  183. this.curType = this.typeData.length ? this.typeData[0].code : ''
  184. this.curIndex = 0
  185. this.getRow()
  186. } else {
  187. this.typeData = []
  188. }
  189. })
  190. },
  191. // 查询列表
  192. getRow(code,num) {
  193. this.curType = code || this.curType
  194. this.curIndex = num || 0
  195. if(this.list[this.curIndex].typeList.length) return
  196. reservePriceFind({code:this.curType}).then(res => {
  197. if (res.status == 200) {
  198. let data = res.data
  199. data.forEach(item =>{
  200. item.rubbishWeight = ''
  201. item.totalAmount = ''
  202. })
  203. this.$nextTick(()=>{
  204. this.list[this.curIndex].typeList = data
  205. console.log(this.list[this.curIndex].typeList,this.curIndex,'----------lllll22222222')
  206. })
  207. } else {
  208. this.list[this.curIndex].typeList = []
  209. this.total = 0
  210. this.noDataText = res.message
  211. }
  212. })
  213. },
  214. // 选择支付方式
  215. chooseType(code) {
  216. this.payType = code
  217. console.log(this.payType,'this.payType')
  218. },
  219. // 提交
  220. submit() {
  221. // uni.redirectTo({
  222. // url: '/pages/order/finish?money=' + 12
  223. // })
  224. // return
  225. let arr = []
  226. this.list.map(item =>{
  227. item.typeList.map(k =>{
  228. if(k.rubbishWeight !=='') {
  229. let p = {
  230. rubbishType: item.typeCode, //垃圾大类型
  231. rubbishTypeItem: k.code, // 垃圾细分类型
  232. rubbishWeight: k.rubbishWeight*1000, // 垃圾重量(克)
  233. rubbishPrice: k.customerPrice, // 单价
  234. totalAmount: k.rubbishWeight* k.customerPrice // 总价金额
  235. }
  236. arr.push(p)
  237. }
  238. })
  239. })
  240. if(arr.length==0) {
  241. uni.showToast({
  242. title: '请先输入回收品类的重量!',
  243. icon: 'none'
  244. })
  245. return
  246. }
  247. if (!this.payType) {
  248. uni.showToast({
  249. title: '请选择支付方式!',
  250. icon: 'none'
  251. })
  252. return
  253. }
  254. let params = {
  255. "payType": this.payType, //支付方式
  256. originalAmount: this.originalAmount, // 支付总金额
  257. totalWeight: this.totalWeight*1000, // 总重量(g)
  258. contactName: this.orderInfo.contactName, //联系人姓名
  259. contactMobile: this.orderInfo.contactMobile, //联系人手机号
  260. contactAddress: this.orderInfo.contactAddress,//联系人地址
  261. orderReserveNo: this.orderReserveNo,
  262. orderReserveItemEntityList: arr
  263. }
  264. this.loading = true
  265. orderSubmit(params).then(res=>{
  266. if(res.status == 200) {
  267. uni.showToast({
  268. title: res.message,
  269. icon: 'none'
  270. })
  271. uni.redirectTo({
  272. url: '/pages/order/finish?money=' + res.data
  273. })
  274. }
  275. this.loading = false
  276. })
  277. }
  278. },
  279. }
  280. </script>
  281. <style lang="scss">
  282. .order-pages {
  283. width: 100%;
  284. height: 100vh;
  285. display: flex;
  286. flex-direction: column;
  287. background-color: #F5F5F5;
  288. .order-info {
  289. width: 100%;
  290. flex: 1;
  291. overflow-y: scroll;
  292. // 订单内容
  293. .info-main{
  294. background: #ffffff;
  295. padding: 10upx 32upx;
  296. margin: 20upx 32upx;
  297. border-radius: 24upx;
  298. box-shadow: 1px 1px 3px #EEEEEE;
  299. font-size: 28upx;
  300. background-image: url(../../static/order_bg_stor.png);
  301. background-repeat: no-repeat;
  302. height: 260rpx;
  303. .new-left{
  304. width: 360rpx;
  305. font-size: 36rpx;
  306. color: #191919;
  307. font-weight: 600;
  308. line-height: 44rpx;
  309. margin-top: 30rpx;
  310. }
  311. .time{
  312. padding: 20rpx 0;
  313. font-size: 32rpx;
  314. color: #7C7D7E;
  315. margin-top: 20rpx;
  316. view:last-child{
  317. font-size: 28rpx;
  318. color: #4C4C4C;
  319. margin-left: 6rpx;
  320. }
  321. }
  322. }
  323. // 状态
  324. .order-status {
  325. padding: 30upx 0;
  326. text-align: center;
  327. .status-title {
  328. font-size: 42upx;
  329. color: #191919;
  330. .icon{
  331. width: 48rpx;
  332. height: 48rpx;
  333. margin-right: 10rpx;
  334. }
  335. }
  336. .status-care {
  337. font-size: 28upx;
  338. margin-top: 10upx;
  339. color: #191919;
  340. >text {
  341. color: red;
  342. }
  343. }
  344. }
  345. // 订单信息列
  346. .item-info{
  347. border-radius: 24rpx;
  348. margin: 0rpx 32rpx 20rpx;
  349. padding: 0rpx 32rpx;
  350. background-color: #fff;
  351. .item-title{
  352. font-size: 32rpx;
  353. color: #181818;
  354. padding-top: 28rpx;
  355. .care{
  356. font-size: 24rpx;
  357. color: #FF2C5C;
  358. margin-top: 10rpx;
  359. }
  360. }
  361. .table{
  362. padding: 20rpx 0;
  363. display: flex;
  364. font-size: 28rpx;
  365. view{
  366. width: 33%;
  367. text-align: center;
  368. }
  369. }
  370. .item{
  371. padding: 28rpx 0;
  372. font-size: 32rpx;
  373. border-bottom: 1px solid #EBEBEB;
  374. :first-child{
  375. color: #7C7D7E;
  376. }
  377. :last-child-child{
  378. color: #222222;
  379. }
  380. &:last-child{
  381. border-bottom: none;
  382. }
  383. .input-left{
  384. padding: 6rpx;
  385. border-bottom: 1px solid #707070;
  386. }
  387. .item-type{
  388. padding: 0 20rpx;
  389. height: 56rpx;
  390. border: 1px solid #979797;
  391. opacity: 1;
  392. border-radius: 28rpx;
  393. font-size: 24rpx;
  394. color: #999999;
  395. text-align: center;
  396. line-height: 56rpx;
  397. margin-right: 20rpx;
  398. }
  399. .item-type.active{
  400. background-color: #4F88F7;
  401. border: none;
  402. color: #fff;
  403. }
  404. }
  405. }
  406. .price-text {
  407. font-size: 20upx;
  408. margin-left: 10upx;
  409. }
  410. .price-num {
  411. font-size: 32upx;
  412. color: red;
  413. font-weight: 600;
  414. margin-right: 6rpx;
  415. }
  416. .u-cell {
  417. padding: 10rpx 32rpx;
  418. }
  419. }
  420. .footer {
  421. padding: 20rpx 32rpx;
  422. display: flex;
  423. background-color: #fff;
  424. }
  425. }
  426. </style>