newBulitOrder.vue 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155
  1. <template>
  2. <view class="page">
  3. <!-- 地址 -->
  4. <view class="address" @click="toadd">
  5. <view class="u-flex u-row-between">
  6. <view class="add" v-if="JSON.stringify(addinfo) != '{}'">{{
  7. addinfo.full_address
  8. }}</view>
  9. <view class="" v-else>{{ i18n.shippingaddress }}</view>
  10. <u-icon name="arrow-right" size="16"></u-icon>
  11. </view>
  12. <view class="info" v-if="JSON.stringify(addinfo) != '{}'">
  13. <text>{{ addinfo.name }}</text>
  14. <text style="margin-left: 20rpx">{{
  15. replacePhoneToStar(addinfo.mobile)
  16. }}</text>
  17. </view>
  18. </view>
  19. <!-- 地址 -->
  20. <!-- 需要下单的商品列表 -->
  21. <Commodity :goodsList="goodsList" />
  22. <!-- 需要下单的商品列表 -->
  23. </view>
  24. </template>
  25. <script>
  26. import Commodity from "./component/commodity.vue";
  27. export default {
  28. components: {
  29. Commodity,
  30. },
  31. data() {
  32. return {
  33. addinfo: {}, //地址信息
  34. province_id: "",
  35. containerList: [],
  36. transport_type_id: "", //运输方式ID
  37. transportTypeName: "", //运输方式名称
  38. swiptlist: [], //推荐商品
  39. goodsList: [], //需要下单的商品
  40. };
  41. },
  42. computed: {
  43. i18n() {
  44. return this.$t("index");
  45. },
  46. },
  47. onLoad(options) {
  48. this.goodsList = JSON.parse(decodeURIComponent(options.goodsList));
  49. console.log(this.goodsList);
  50. },
  51. methods: {
  52. //跳转到填写地址
  53. toadd() {
  54. var that = this;
  55. uni.navigateTo({
  56. url: "/pageC/addressManagement/addressManagement?tabs=" + Number(0),
  57. events: {
  58. getadd(res) {
  59. that.addinfo = res;
  60. that.province_id = res.province_id;
  61. that.transport();
  62. },
  63. },
  64. });
  65. },
  66. //货运类型列表
  67. transport() {
  68. uni.$u.http
  69. .get("/api/transport-type", {
  70. params: {
  71. province_id: this.province_id,
  72. },
  73. })
  74. .then((res) => {
  75. this.containerList = res;
  76. this.transport_type_id = res[0].id;
  77. //根据不同的语言选择不用的类型
  78. if (this.language == "zh-CN") {
  79. this.type = res[0].name_cn;
  80. }
  81. if (this.language == "en-US") {
  82. this.type = res[0].name_en;
  83. }
  84. if (this.language == "es-ES") {
  85. this.type = res[0].name_es;
  86. }
  87. if (this.language == "it-IT") {
  88. this.type = res[0].name_ita;
  89. }
  90. })
  91. .catch(() => {});
  92. },
  93. //正则匹配手机号
  94. replacePhoneToStar: function (phone) {
  95. if (phone) {
  96. return phone.replace(/(\d{3})\d{4}(\d{4})/, "$1****$2");
  97. }
  98. },
  99. //商品推荐
  100. recommend() {
  101. uni.$u.http
  102. .post("/api/goods/recommend", {
  103. keyword: "",
  104. })
  105. .then((res) => {
  106. this.swiptlist = res;
  107. })
  108. .catch(() => {});
  109. },
  110. },
  111. };
  112. </script>
  113. <style scoped lang="scss">
  114. .page {
  115. background: rgba(244, 244, 244, 1);
  116. padding: 20rpx 24rpx;
  117. box-sizing: border-box;
  118. // 地址
  119. .address {
  120. width: 702rpx;
  121. // height: 182rpx;
  122. background: #ffffff;
  123. border-radius: 16rpx;
  124. padding: 32rpx 24rpx;
  125. box-sizing: border-box;
  126. .add {
  127. font-family: SFPro, SFPro;
  128. font-weight: 500;
  129. font-size: 32rpx;
  130. color: #222222;
  131. line-height: 36rpx;
  132. text-align: left;
  133. font-style: normal;
  134. }
  135. .info {
  136. font-family: SFPro, SFPro;
  137. font-weight: 400;
  138. font-size: 24rpx;
  139. color: #555555;
  140. line-height: 28rpx;
  141. text-align: left;
  142. font-style: normal;
  143. margin-top: 20rpx;
  144. }
  145. }
  146. }
  147. </style>