insert.vue 7.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287
  1. <template>
  2. <view>
  3. <navigator url="/store/deliveryAddress/index?title=选择地址" @click="toSelect" class="address-box"
  4. hover-class="navigator-hover">
  5. <view class="empty" v-if="address.contactsid == 0">
  6. 请选择收货地址
  7. </view>
  8. <view class="contacts" v-else>
  9. <view class="label">
  10. <text class="iconfont icon-dizhi-hui" />
  11. <text style="margin-right: 10px;">
  12. {{ address.name }}
  13. </text>
  14. <text>
  15. {{ address.phonenumber }}
  16. </text>
  17. </view>
  18. <view class="address">
  19. {{ getCity(address) }}
  20. </view>
  21. </view>
  22. <view class="iconfont icon-a-wodetiaozhuan" />
  23. </navigator>
  24. <view class="product">
  25. <u--image :src="product.cover" width="86" height="80" radius="8">
  26. <template v-slot:loading>
  27. <u-loading-icon color="red"></u-loading-icon>
  28. </template>
  29. </u--image>
  30. <view class="content">
  31. <view class="title u-line-1">{{ product.name }}</view>
  32. <view class="price-box">
  33. {{ product.pricetype == '一口价' ? '价格' : '定金' }}
  34. <text style="color: #E3041F;margin-left: 4px;">
  35. </text>
  36. <text class="price">
  37. {{ CNY(product.pricetype == '一口价' ? product.price : product.price_deposit, '') }}
  38. </text>
  39. <text style="color: #E3041F;margin-left: 4px;">
  40. </text>
  41. </view>
  42. </view>
  43. </view>
  44. <view class="address-box" hover-class="navigator-hover">
  45. <view class="empty">
  46. 小计
  47. </view>
  48. <view class="price">
  49. {{ CNY(product.pricetype == '一口价' ? product.price : product.price_deposit) }}
  50. </view>
  51. </view>
  52. <view class="footer">
  53. <view class="content">
  54. <view class="price-box">
  55. 总计:
  56. <view class="price">
  57. {{ CNY(product.pricetype == '一口价' ? product.price : product.price_deposit) }}
  58. </view>
  59. </view>
  60. <view class="submit" :class="address.contactsid == 0 || loading ? 'forbidden' : ''"
  61. hover-class="navigator-hover" @click="address.contactsid == 0 || loading ? '' : submit()">
  62. <u-loading-icon v-if="loading" />
  63. <block v-else>
  64. 支付
  65. </block>
  66. </view>
  67. </view>
  68. </view>
  69. </view>
  70. </template>
  71. <script>
  72. export default {
  73. data() {
  74. return {
  75. address: {
  76. contactsid: 0
  77. },
  78. product: {},
  79. loading: false
  80. }
  81. },
  82. onLoad(options) {
  83. if (options.data) {
  84. let data = JSON.parse(decodeURIComponent(options.data))
  85. console.log(data)
  86. this.product = data;
  87. }
  88. this.getDefault()
  89. },
  90. methods: {
  91. getDefault() {
  92. this.$Http.basic({
  93. "id": 20240506103702,
  94. "content": {
  95. "where": {
  96. isdefault: 1
  97. }
  98. },
  99. }).then(res => {
  100. console.log("获取默认地址", res)
  101. if (this.cutoff(res.msg)) return;
  102. if (res.data.length) this.address = res.data[0];
  103. })
  104. },
  105. submit() {
  106. this.loading = true;
  107. let store = uni.getStorageSync("shop") || {};
  108. console.log(this.address)
  109. this.$Http.basic({
  110. "id": 20240429152502,
  111. "content": {
  112. "sa_custorderid": 0,
  113. "items": [
  114. {
  115. "sa_fadid": this.product.sa_fadid,
  116. "qty": 1
  117. }
  118. ],
  119. "rec_contactsid": this.address.contactsid,
  120. "sys_enterpriseid": store.sys_enterpriseid,
  121. "sa_storeid": store.sa_storeid,
  122. "remarks": ""
  123. },
  124. }).then(res => {
  125. this.loading = false;
  126. console.log("创建订单", res)
  127. if (this.cutoff(res.msg)) return;
  128. })
  129. },
  130. toSelect() {
  131. this.$Http.selectAddress = function (address) {
  132. this.address = address;
  133. uni.navigateBack();
  134. delete this.$Http.selectAddress
  135. }.bind(this)
  136. }
  137. },
  138. }
  139. </script>
  140. <style lang="scss" scoped>
  141. .address-box {
  142. display: flex;
  143. align-items: center;
  144. justify-content: space-between;
  145. margin-top: 10px;
  146. width: 100vw;
  147. height: 64px;
  148. background: #FFFFFF;
  149. padding: 0 10px;
  150. box-sizing: border-box;
  151. .empty {
  152. font-family: Source Han Sans SC, Source Han Sans SC;
  153. font-size: 14px;
  154. color: #333333;
  155. }
  156. .price {
  157. font-family: Source Han Sans SC, Source Han Sans SC;
  158. font-size: 16px;
  159. color: #E3041F;
  160. }
  161. .contacts {
  162. .label {
  163. line-height: 20px;
  164. font-family: Source Han Sans SC, Source Han Sans SC;
  165. font-weight: bold;
  166. font-size: 14px;
  167. color: #000000;
  168. .iconfont {
  169. font-size: 12px;
  170. color: #333333;
  171. margin-right: 5px;
  172. }
  173. }
  174. .address {
  175. line-height: 17px;
  176. font-family: Source Han Sans SC, Source Han Sans SC;
  177. font-size: 12px;
  178. color: #666666;
  179. margin-top: 7px;
  180. }
  181. }
  182. }
  183. .product {
  184. display: flex;
  185. width: 100vw;
  186. background: #fff;
  187. padding: 10px;
  188. box-sizing: border-box;
  189. margin-top: 10px;
  190. .content {
  191. margin-left: 20px;
  192. flex: 1;
  193. height: 100%;
  194. .title {
  195. line-height: 24px;
  196. font-family: Source Han Sans SC, Source Han Sans SC;
  197. font-weight: bold;
  198. font-size: 16px;
  199. color: #333333;
  200. margin-top: 10px;
  201. }
  202. .price-box {
  203. margin-top: 10px;
  204. font-size: 12px;
  205. color: #333333;
  206. .price {
  207. color: #E3041F;
  208. font-size: 18px;
  209. font-weight: bold;
  210. }
  211. }
  212. }
  213. }
  214. .footer {
  215. position: fixed;
  216. width: 100vw;
  217. height: 65px;
  218. background: #FFFFFF;
  219. box-shadow: 0px -2px 6px 1px rgba(0, 0, 0, 0.16);
  220. bottom: 0;
  221. left: 0;
  222. padding: 10px;
  223. padding-top: 5px;
  224. box-sizing: border-box;
  225. .content {
  226. display: flex;
  227. align-items: center;
  228. justify-content: space-between;
  229. height: 45px;
  230. width: 100%;
  231. .price-box {
  232. display: flex;
  233. font-size: 14px;
  234. color: #333333;
  235. .price {
  236. color: #E3041F;
  237. font-size: 16px;
  238. font-weight: bold;
  239. }
  240. }
  241. .submit {
  242. display: flex;
  243. align-items: center;
  244. justify-content: center;
  245. width: 100px;
  246. height: 45px;
  247. background: #C30D23;
  248. border-radius: 5px;
  249. font-family: PingFang SC, PingFang SC;
  250. font-size: 14px;
  251. color: #FFFFFF;
  252. }
  253. }
  254. }
  255. .forbidden {
  256. opacity: .6;
  257. }
  258. </style>