order.vue 6.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304
  1. <template>
  2. <!-- #ifdef H5 -->
  3. <zj-page-layout :hasFooter="true">
  4. <view class="all-container">
  5. <view class="common-title">订单信息</view>
  6. <view class="product-container card">
  7. <view class="it" v-for="(item, index) in goodsList" :key="index">
  8. <view class="name"
  9. >{{ item.goodsName }}<text>×{{ item.num }}{{ item.goodsSalesUnit }}</text></view
  10. >
  11. <view class="price">¥{{ (item.price * item.num) | priceFilter }}</view>
  12. </view>
  13. <view class="total">
  14. <view class="text">合计:</view>
  15. <view class="price">¥{{ totalPrice | priceFilter }}</view>
  16. </view>
  17. </view>
  18. <block v-if="websitData">
  19. <view class="common-title">提货信息</view>
  20. <view class="info-container card" v-if="websitData">
  21. <view class="top">
  22. <view class="left">{{ websitData.name }}</view>
  23. <view class="right">距离{{ (websitData.distance / 1000).toFixed(2) }}KM</view>
  24. </view>
  25. <view class="row">
  26. <view class="label">联系电话</view>
  27. <view class="value">{{ websitData.websitPhone }}</view>
  28. </view>
  29. <view class="row">
  30. <view class="label">提货地址</view>
  31. <view class="value">{{ websitData.address }}</view>
  32. </view>
  33. </view>
  34. </block>
  35. <view class="common-title">备注</view>
  36. <view class="remark-container card">
  37. <u--textarea v-model="remark" placeholder="请输入内容" border="none" autoHeight></u--textarea>
  38. </view>
  39. </view>
  40. <template slot="footer">
  41. <view class="bottom-container">
  42. <view class="left">
  43. <view class="text">共{{ totalNum }}件,合计:</view>
  44. <view class="price">¥{{ totalPrice | priceFilter }}</view>
  45. </view>
  46. <view class="btn">
  47. <u-button type="primary" text="确认订单" @click="submitData"></u-button>
  48. </view>
  49. </view>
  50. </template>
  51. </zj-page-layout>
  52. <!-- #endif -->
  53. <!-- #ifndef H5 -->
  54. <web-view
  55. :src="webViewHref(`/packageMaterial/pages/apply/order`, pam, crossPagePam)"
  56. @message="crossPage.$listener"
  57. ></web-view>
  58. <!-- #endif -->
  59. </template>
  60. <script>
  61. // #ifdef H5
  62. import wx from 'weixin-js-sdk'
  63. export default {
  64. data() {
  65. return {
  66. type: 'M',
  67. applyName: '',
  68. websitId: null,
  69. websitName: null,
  70. goodsList: [],
  71. lat: '',
  72. lng: '',
  73. websitData: null,
  74. userInfo: {},
  75. remark: '',
  76. }
  77. },
  78. computed: {
  79. totalNum() {
  80. // let val = 0;
  81. // this.goodsList.forEach(item => {
  82. // val = val + item.num;
  83. // })
  84. return this.goodsList.length;
  85. },
  86. totalPrice() {
  87. let val = 0;
  88. this.goodsList.forEach(item => {
  89. val = val + (item.num * (item.price * 100) / 100);
  90. })
  91. return val;
  92. },
  93. },
  94. async onLoad() {
  95. let data = this.$getStorage('materialApplyData');
  96. if(data) {
  97. this.type = data.type;
  98. this.applyName = data.applyName;
  99. this.websitId = data.websitId;
  100. this.websitName = data.websitName;
  101. this.goodsList = data.goodsList;
  102. }
  103. this.$removeStorage('materialApplyData');
  104. this.userInfo = await this.$getUserInfo();
  105. await this.getLocation();
  106. this.getWebsitList();
  107. },
  108. methods: {
  109. // 获取位置
  110. async getLocation() {
  111. return await new Promise((resolve, reject) => {
  112. wx.getLocation({
  113. type: 'gcj02',
  114. isHighAccuracy: true,
  115. geocode: true,
  116. success: (res) => {
  117. this.lat = res.latitude;
  118. this.lng = res.longitude;
  119. resolve(res);
  120. },
  121. fail: (res) => {
  122. reject(0);
  123. }
  124. });
  125. });
  126. },
  127. getWebsitList() {
  128. this.$api.get('/user/apply/websit', {
  129. lat: this.lat,
  130. lng: this.lng,
  131. }).then(res => {
  132. this.websitData = res.data.find(o => o.websitId == this.websitId)
  133. })
  134. },
  135. submitData() {
  136. this.$api.postJson('/material/salses/add', {
  137. goodsType: this.type,
  138. remark: this.remark,
  139. workerId: this.userInfo.userId,
  140. workerName: this.userInfo.nickName,
  141. companyWechatId: this.userInfo.companyWechatId,
  142. websitId: this.websitId,
  143. websitName: this.websitName,
  144. websitBuyGoods: this.goodsList,
  145. }).then(res => {
  146. this.$navToPage(
  147. {
  148. url: `/packageMaterial/pages/stock/buyRecord`
  149. },
  150. 'reLaunch'
  151. )
  152. // this.$navToPage({
  153. // url: `/packageMaterial/pages/apply/pay?orderId=${res.data}&websitId=${this.websitId}&goodsType=${this.type}`
  154. // })
  155. })
  156. },
  157. },
  158. }
  159. // #endif
  160. // #ifndef H5
  161. export default {
  162. data() {
  163. return {
  164. pam: {},
  165. }
  166. },
  167. onLoad(pam) {
  168. this.pam = pam;
  169. }
  170. }
  171. // #endif
  172. </script>
  173. <style lang="scss" scoped>
  174. .all-container {
  175. padding: 0 20rpx;
  176. }
  177. .common-title {
  178. font-size: 32rpx;
  179. font-weight: 600;
  180. margin-top: 30rpx;
  181. }
  182. .card {
  183. @include zj-card;
  184. margin-top: 20rpx;
  185. padding: 30rpx;
  186. }
  187. .product-container {
  188. .it {
  189. display: flex;
  190. align-items: flex-end;
  191. margin-bottom: 20rpx;
  192. .name {
  193. flex: 1;
  194. font-size: 28rpx;
  195. font-weight: 500;
  196. text {
  197. color: $sec-font;
  198. margin-left: 12rpx;
  199. font-weight: normal;
  200. }
  201. }
  202. .price {
  203. margin-left: 30rpx;
  204. font-size: 28rpx;
  205. font-weight: 500;
  206. }
  207. }
  208. .total {
  209. display: flex;
  210. align-items: center;
  211. justify-content: flex-end;
  212. margin-top: 30rpx;
  213. .text {
  214. font-size: 28rpx;
  215. color: $sec-font;
  216. }
  217. .price {
  218. font-size: 28rpx;
  219. color: $minor-color;
  220. font-weight: 500;
  221. }
  222. }
  223. }
  224. .info-container {
  225. .top {
  226. display: flex;
  227. align-items: center;
  228. justify-content: space-between;
  229. .left {
  230. font-weight: 500;
  231. }
  232. .right {
  233. font-size: 28rpx;
  234. }
  235. }
  236. .row {
  237. display: flex;
  238. align-items: center;
  239. margin-top: 20rpx;
  240. .label {
  241. font-size: 28rpx;
  242. color: $sec-font;
  243. margin-right: 20rpx;
  244. }
  245. .value {
  246. flex: 1;
  247. font-size: 28rpx;
  248. text {
  249. color: $minor-color;
  250. }
  251. &.price {
  252. color: $theme-color;
  253. }
  254. }
  255. .tag {
  256. font-size: 28rpx;
  257. color: $theme-color;
  258. }
  259. }
  260. }
  261. .remark-container {
  262. padding: 0;
  263. ::v-deep .u-textarea {
  264. padding: 20rpx 30rpx;
  265. min-height: 200rpx;
  266. }
  267. }
  268. .bottom-container {
  269. padding: 20rpx;
  270. display: flex;
  271. align-items: center;
  272. justify-content: space-between;
  273. .left {
  274. display: flex;
  275. align-items: center;
  276. .text {
  277. font-size: 28rpx;
  278. color: $sec-font;
  279. }
  280. .price {
  281. font-size: 32rpx;
  282. color: $minor-color;
  283. font-weight: 500;
  284. }
  285. }
  286. .btn {
  287. width: 180rpx;
  288. }
  289. }
  290. </style>