address.vue 6.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318
  1. <template>
  2. <view class="intro-page common">
  3. <view class="top-class"></view>
  4. <view class="title">
  5. 收货地址
  6. </view>
  7. <view class="head">
  8. <u-row class="row-class">
  9. <u-col span="4">
  10. <image class="logo-img" src="/static/images/common/logo.png" mode="aspectFit" />
  11. </u-col>
  12. <u-col span="4">
  13. <!-- <image class="commodity-img" src="/static/images/common/commodity.png" mode="aspectFit" /> -->
  14. </u-col>
  15. <u-col span="4">
  16. </u-col>
  17. </u-row>
  18. </view>
  19. <view class="theme-text">
  20. <image src="https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/text.png"
  21. class="textImage"></image>
  22. </view>
  23. <view class="intro-card">
  24. <view class="intro-view">
  25. <view class="intro-label">
  26. <view class="label-title">
  27. 收货地址
  28. </view>
  29. </view>
  30. <view class="content">
  31. <view class="from">
  32. <u--form labelPosition="left" :model="model1" :rules="rules" ref="uForm">
  33. <u-form-item label="联系电话:" prop="userInfo.phone" ref="item1">
  34. <u--input v-model="model1.userInfo.phone" border="none"></u--input>
  35. </u-form-item>
  36. <u-form-item label="联系人:" prop="userInfo.name" ref="item1">
  37. <u--input v-model="model1.userInfo.name" border="none"></u--input>
  38. </u-form-item>
  39. <u-form-item label="收货地址:" ref="item1">
  40. <u--textarea v-model="model1.userInfo.address" border="none"></u--textarea>
  41. </u-form-item>
  42. </u--form>
  43. </view>
  44. </view>
  45. </view>
  46. </view>
  47. <u-toast ref="uToast"></u-toast>
  48. <!-- 返回按钮 -->
  49. <view class="footer-btn">
  50. <view @click="saveData" class="return-button" style="margin-right: 180rpx;">保存</view>
  51. <view @click="goBack" class="return-button" >返回</view>
  52. </view>
  53. </view>
  54. </template>
  55. <script>
  56. import {
  57. getMiniAppUserAddress,editMiniAppUserAddress
  58. } from '@/api/scan'
  59. export default {
  60. data() {
  61. return {
  62. scanCode: '',
  63. model1: {
  64. userInfo: {
  65. phone: '',
  66. address: '',
  67. name: ''
  68. },
  69. },
  70. rules: {
  71. 'userInfo.name': {
  72. type: 'string',
  73. required: true,
  74. message: '请填写姓名',
  75. trigger: ['blur', 'change']
  76. },
  77. 'userInfo.phone': [{
  78. required: true,
  79. message: '请输入手机号',
  80. trigger: ['change', 'blur'],
  81. },
  82. {
  83. // 自定义验证函数,见上说明
  84. validator: (rule, value, callback) => {
  85. console.log(value);
  86. // 上面有说,返回true表示校验通过,返回false表示不通过
  87. // uni.$u.test.mobile()就是返回true或者false的
  88. return uni.$u.test.mobile(value);
  89. },
  90. message: '手机号码不正确',
  91. // 触发器可以同时用blur和change
  92. trigger: ['change', 'blur'],
  93. }
  94. ],
  95. },
  96. }
  97. },
  98. onReady() { // 如果需要兼容微信小程序,并且校验规则中含有方法等,只能通过setRules方法设置规则
  99. this.$refs.uForm.setRules(this.rules)
  100. },
  101. onLoad() {
  102. this.scanCode = uni.getStorageSync('scanCode');
  103. this.getMiniAppUserAddress();
  104. },
  105. methods: {
  106. getMiniAppUserAddress(){
  107. getMiniAppUserAddress().then(data => {
  108. if (data.code == 0){
  109. this.model1.userInfo.name = data.data.contact_name;
  110. this.model1.userInfo.phone = data.data.contact_phone;
  111. this.model1.userInfo.address = data.data.address;
  112. }
  113. })
  114. },
  115. goBack() {
  116. uni.navigateBack();
  117. },
  118. onFilterChange(val) {
  119. if (this.filterStatus !== val) {
  120. this.filterStatus = val;
  121. }
  122. },
  123. saveData() {
  124. let that = this;
  125. this.$refs.uForm.validate().then(res => {
  126. editMiniAppUserAddress(that.model1.userInfo).then(data => {
  127. let params = {
  128. type: "success",
  129. title: "成功主题(带图标)",
  130. message: "提交成功",
  131. iconUrl: "https://uviewui.com/demo/toast/success.png",
  132. }
  133. this.$refs.uToast.show({
  134. ...params
  135. });
  136. })
  137. }).catch(errors => {
  138. })
  139. }
  140. }
  141. }
  142. </script>
  143. <style lang="scss" scoped>
  144. @import url('../../../static/scss/common.css');
  145. .row-class {
  146. height: 80rpx;
  147. }
  148. .logo-img {
  149. background-size: cover;
  150. /* 确保背景图片自适应填充整个容器 */
  151. background-position: center;
  152. /* 背景图片居中显示 */
  153. background-repeat: no-repeat;
  154. /* 防止背景图重复 */
  155. height: 42rpx;
  156. width: 62%;
  157. }
  158. .commodity-img {
  159. background-size: cover;
  160. /* 确保背景图片自适应填充整个容器 */
  161. background-position: center;
  162. /* 背景图片居中显示 */
  163. background-repeat: no-repeat;
  164. /* 防止背景图重复 */
  165. height: 35rpx;
  166. width: 100%;
  167. }
  168. .theme-text {
  169. height: 10vh;
  170. text-align: center;
  171. line-height: 11vh;
  172. .textImage {
  173. height: 80rpx;
  174. width: 400rpx;
  175. }
  176. }
  177. .intro-card {
  178. margin: 0 32rpx;
  179. padding: 32rpx 24rpx 24rpx 24rpx;
  180. background: rgba(131, 100, 71, 0.5);
  181. border-radius: 10rpx;
  182. .intro-view {
  183. border: 1px solid #341B10;
  184. padding: 10px;
  185. margin-top: 20rpx;
  186. position: relative;
  187. height: 58vh;
  188. .intro-label {
  189. background-image:
  190. url("https://hyscancode.oss-cn-hangzhou.aliyuncs.com/xiaochengxu/guzhenganzi/label.png");
  191. /* 使用绝对路径 */
  192. background-size: contain;
  193. background-repeat: no-repeat;
  194. width: 220rpx;
  195. height: 120rpx;
  196. position: absolute;
  197. margin-top: -70rpx;
  198. align-content: center;
  199. .label-title {
  200. font-weight: bold;
  201. font-size: 30rpx;
  202. color: #341B10;
  203. text-align: center;
  204. margin-left: 10px;
  205. height: 120rpx;
  206. line-height: 110rpx;
  207. }
  208. }
  209. .intro-content {
  210. font-size: 26rpx;
  211. color: #5c4322;
  212. line-height: 1.8;
  213. text-align: justify;
  214. margin-top: 20rpx;
  215. }
  216. }
  217. }
  218. .u-form-item{
  219. margin-bottom: 20rpx;
  220. }
  221. ::v-deep .u-form-item__body__left {
  222. width: 160rpx !important;
  223. }
  224. ::v-deep .u-form-item__body__left__content__label {
  225. font-weight: bold;
  226. font-size: 26rpx !important;
  227. color: #FFFFFF !important;
  228. }
  229. ::v-deep .u-form-item__body__right {
  230. border: 1px solid #9B0000 !important;
  231. }
  232. ::v-deep .u-textarea {
  233. background-color: rgba(0, 0, 0, 0) !important;
  234. }
  235. ::v-deep .u-form-item__body {
  236. display: flex;
  237. flex-direction: row;
  238. padding: 0 0 !important;
  239. padding-top: 10rpx !important;
  240. }
  241. ::v-deep .u-form-item__body__right__message {
  242. margin-left: 160rpx !important;
  243. }
  244. ::v-deep .row-class-footer .u-row{
  245. width: 100vw !important;
  246. }
  247. .filter-btn-group {
  248. display: flex;
  249. justify-content: flex-start;
  250. align-items: center;
  251. gap: 24rpx;
  252. margin: 10rpx 0 10rpx 0;
  253. }
  254. .filter-btn {
  255. padding: 4rpx 20rpx;
  256. border: 2rpx solid #b22222;
  257. color: #b22222;
  258. font-size: 28rpx;
  259. transition: all 0.2s;
  260. margin-left: 10rpx;
  261. }
  262. .filter-btn.active {
  263. background: #b22222;
  264. color: #fff;
  265. border: 2rpx solid #b22222;
  266. }
  267. .row-text {
  268. font-weight: bold;
  269. font-size: 26rpx;
  270. color: #FFFFFF;
  271. }
  272. .content {
  273. max-height: 60vh;
  274. overflow: auto;
  275. margin-top: 20px;
  276. }
  277. .savaBtn {
  278. margin-top: 10px;
  279. font-weight: 600;
  280. }
  281. </style>