newdizhi.vue 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442
  1. <template>
  2. <view class="contentV">
  3. <customNav :shownav="true" :title="$t('index.shouhuodz')" titledetl=""></customNav>
  4. <view class="topaddrCTV bottomline">
  5. <view class="contentInRowS" @click="selectDizhi">
  6. <view class="contentColumn">
  7. <text class="areaT textfontB4">{{area}}</text>
  8. <text class="addressT textfontB5">{{xingzhengqw}}</text>
  9. </view>
  10. <image class="slot-image" src="/static/images/dizhil@3x.png" mode="widthFix"></image>
  11. </view>
  12. </view>
  13. <text class="linesp"></text>
  14. <view class="inputctV">
  15. <text>{{$t('index.xiangxidz')}}</text>
  16. <input class="inputV" type="text" :disabled="jinzhishur" :value="address" :placeholder="$t('index.qsrxiangxidz')" @input="addressinput">
  17. </view>
  18. <text class="linesp"></text>
  19. <view class="inputctV">
  20. <text>{{$t('index.lianxiren')}}</text>
  21. <view class="ctinrow">
  22. <input class="inputV" type="text" :disabled="jinzhishur" :value="name" :placeholder="$t('index.qsrlianxiren')" @input="nameinput">
  23. <!-- <radio-group @change="radioChange">
  24. <radio value="y" />
  25. {{$t('index.xiansheng')}}
  26. <radio value="x"/>
  27. {{$t('index.nvshi')}}
  28. </radio-group> -->
  29. </view>
  30. </view>
  31. <text class="linesp"></text>
  32. <view class="inputctV">
  33. <text>{{$t('order.lianxidianhua')}}</text>
  34. <view class="ctinrow">
  35. <!-- <view class="xialakuang" @click="popgjm">
  36. <text>{{guojiadaima}}</text>
  37. <image style="width: 36rpx;height: 36rpx;padding-right: 16rpx;" src="/static/images/xiala@3x.png" mode="scaleToFill"></image>
  38. </view> -->
  39. <input class="inputphone" type="number" :disabled="jinzhishur" :value="phone" :placeholder="$t('index.shoujihao')" @input="phoneinput">
  40. </view>
  41. </view>
  42. <view class="contentInRowL" style="margin-left: 5%;margin-top: 50rpx;">
  43. <text>{{$t('order.menpaizp')}}</text>
  44. </view>
  45. <view class="contentColumnC" style="margin-top: 30rpx;">
  46. <yhdslCropper ref="yhdslCropper" :quality="1" mode="scale" @uploadImg="uploadImg" :scale="scale"></yhdslCropper>
  47. <image class="imagV" :src="baseUrl+mpImage" mode="scaleToFill" @click="selectImage"></image>
  48. </view>
  49. <view class="contentColumnC" style="margin-top: 50rpx;">
  50. <text class="savebt" @click="updataAddr">{{$t('index.tijiao')}}</text>
  51. <text v-if="id>=0" class="delbt" @click="deleteAddr">{{$t('index.sanchu')}}</text>
  52. </view>
  53. <view style="height: 60rpx;"></view>
  54. <popViewGG :tips="$t('index.gjqhxz')" :show="showpop" :acttips="$t('order.queding')" :maskClosable="true" :isCancel="true" @chooseCancel="chooseCancel">
  55. <picker-view :indicator-style="indicatorStyle" :value="pvalue" @change="bindChange" class="picker-view">
  56. <picker-view-column>
  57. <view class="item" v-for="(item,index) in range" :key="index">{{item}}</view>
  58. </picker-view-column>
  59. </picker-view>
  60. </popViewGG>
  61. </view>
  62. </template>
  63. <script>
  64. import yhdslCropper from '@/components/yhdsl-cropper/yhdsl-cropper.vue';
  65. import api from "@/pages/api/api.js"
  66. export default {
  67. components: {
  68. yhdslCropper
  69. },
  70. data() {
  71. return {
  72. pvalue: [0],
  73. indicatorStyle: `height: 50px;`,
  74. range: ["+86","+84","+886"],
  75. showpop:false,
  76. guojiadaima:'+86',
  77. latitude: 0,
  78. longitude: 0,
  79. country:'',
  80. province:'',
  81. city: "",
  82. area: '',
  83. address: "",
  84. phone:'',
  85. name:'',
  86. annexes:'',
  87. id:-1,
  88. xingzhengqw:this.$t('mend.qingxzdz'),
  89. jinzhishur:false,
  90. scale:1,
  91. baseUrl:this.$baseImagurl,
  92. mpImage:''
  93. }
  94. },
  95. onLoad(option) {
  96. this.id = option.id;
  97. if(this.id>=0){
  98. this.getaddressxq(this.id);
  99. }
  100. },
  101. onShow() {
  102. this.gettempLocate();
  103. if(this.latitude==0||this.longitude==0){
  104. this.jinzhishur=true;
  105. }
  106. else{
  107. this.jinzhishur=false;
  108. }
  109. },
  110. methods: {
  111. radioChange(e){
  112. console.log(e.detail.value)
  113. },
  114. bindChange (e) {
  115. var val = e.detail.value[0];
  116. this.guojiadaima=this.range[val];
  117. },
  118. popgjm(){
  119. this.showpop=true;
  120. },
  121. chooseCancel(){
  122. this.showpop=false;
  123. },
  124. addressinput(event){
  125. this.address = event.target.value;
  126. },
  127. nameinput(event){
  128. this.name = event.target.value;
  129. },
  130. phoneinput(event){
  131. this.phone = event.target.value;
  132. },
  133. selectDizhi(){
  134. uni.navigateTo({
  135. url:'/pages/UserCenter/map/Chazhaodizhi'
  136. })
  137. },
  138. gettempLocate(){
  139. try {//读取
  140. var data = uni.getStorageSync("tempLocation");
  141. if(''==data || undefined==data || null==data){
  142. return;
  143. }
  144. else{
  145. this.latitude=data.latitude;
  146. this.longitude=data.longitude;
  147. this.address=data.address;
  148. this.xingzhengqw=data.address;
  149. this.area=data.name;
  150. uni.setStorageSync('userAddrLocation',"");
  151. uni.setStorageSync('tempLocation',"");
  152. return;
  153. }
  154. } catch(e){//错误
  155. return;
  156. }
  157. },
  158. selectImage(){
  159. this.$refs.yhdslCropper.chooseImage();
  160. },
  161. uploadImg(e) {
  162. console.log('------------uploadImg:',e)
  163. this.spImage = e;
  164. var that = this;
  165. uni.uploadFile({
  166. url: this.$upImagurl, //上传图片api
  167. filePath: e,
  168. name: 'file',
  169. header:{
  170. //"Authorization": userinfo.token
  171. },
  172. success: (res) => {
  173. let group = JSON.parse(res.data);
  174. that.mpImage=group.data;
  175. console.log(group)
  176. uni.showToast({
  177. title:that.$t('mend.shangccg'),
  178. icon:"success"
  179. })
  180. }
  181. });
  182. },
  183. getaddressxq(id){
  184. api('getaddressxq',{
  185. id: id
  186. },r=>{
  187. console.log('getaddressxq:',r);
  188. this.latitude=r.data.data.latitude;
  189. this.longitude=r.data.data.longitude;
  190. this.address=r.data.data.address;
  191. this.xingzhengqw=r.data.data.address;
  192. this.phone=r.data.data.phone;
  193. this.area=r.data.data.area;
  194. this.name=r.data.data.name;
  195. this.mpImage=r.data.data.annexes;
  196. this.jinzhishur=false;
  197. },failc=>{
  198. //console.log('getadvertis----',failc)
  199. })
  200. },
  201. updataAddr(){
  202. if(this.address.length<1){
  203. uni.showToast({
  204. title:this.$t('index.qsrxiangxidz'),
  205. icon:"none"
  206. })
  207. return;
  208. }
  209. if(this.name.length<1){
  210. uni.showToast({
  211. title:this.$t('index.qsrlianxiren'),
  212. icon:"none"
  213. })
  214. return;
  215. }
  216. if(this.phone.length<1){
  217. uni.showToast({
  218. title:this.$t('index.shoujihao'),
  219. icon:"none"
  220. })
  221. return;
  222. }
  223. this.postaddress();
  224. },
  225. deleteAddr(){
  226. if(this.id<0){
  227. console.log('未提交的新地址');
  228. }
  229. else{
  230. var that = this;
  231. uni.showModal({
  232. cancelText:that.$t('order.quxiao'),
  233. confirmText:that.$t('comp.queren'),
  234. title: that.$t('api.message'),
  235. content:that.$t('index.shanchuAddr'),
  236. success: function (res) {
  237. if (res.confirm) { //这里是点击了确定以后
  238. that.deleaddress();
  239. } else { //这里是点击了取消以后
  240. console.log('点击取消')
  241. }
  242. }
  243. })
  244. }
  245. },
  246. deleaddress(){
  247. api('deleaddress',{
  248. id:this.id
  249. },res=>{
  250. console.log('deleaddress:',res);
  251. uni.navigateBack();
  252. },failc=>{
  253. //console.log('getadvertis----',failc)
  254. })
  255. },
  256. postaddress(){
  257. var addr;
  258. if(this.id<0){
  259. addr={
  260. name:this.name,
  261. phone:this.phone,
  262. address: this.address,
  263. longitude:this.longitude,
  264. latitude: this.latitude,
  265. country:'',
  266. province:'',
  267. city:'',
  268. area:this.area,
  269. annexes:this.mpImage
  270. }
  271. }
  272. else{
  273. addr={
  274. id:this.id,
  275. name:this.name,
  276. phone:this.phone,
  277. address: this.address,
  278. longitude:this.longitude,
  279. latitude: this.latitude,
  280. country:'',
  281. province:'',
  282. city:'',
  283. area:this.area,
  284. annexes:this.mpImage
  285. }
  286. }
  287. console.log('addr:',addr);
  288. api('ADDaddress',addr,
  289. res=>{
  290. console.log('getGoodsDetail:',res);
  291. uni.navigateBack();
  292. },failc=>{
  293. //console.log('getadvertis----',failc)
  294. })
  295. },
  296. }
  297. }
  298. </script>
  299. <style>
  300. .contentV{
  301. width: 100%;
  302. position: relative;
  303. height: 94vh;
  304. }
  305. .linesp{
  306. width: 100%;
  307. height: 8rpx;
  308. background-color: aliceblue;
  309. }
  310. .topaddrCTV{
  311. margin-top: 60rpx;
  312. padding-bottom: 20rpx;
  313. width: 90%;
  314. margin-left: 5%;
  315. }
  316. .bottomline{
  317. border: solid lightgray;
  318. border-width: 0px 0px 2rpx 0px;
  319. }
  320. .areaT{
  321. overflow: hidden;
  322. text-overflow: ellipsis;
  323. display: -webkit-box;
  324. -webkit-line-clamp: 2;
  325. -webkit-box-orient: vertical;
  326. }
  327. .addressT{
  328. overflow: hidden;
  329. text-overflow: ellipsis;
  330. display: -webkit-box;
  331. -webkit-line-clamp: 2;
  332. -webkit-box-orient: vertical;
  333. }
  334. .slot-image {
  335. /* #ifndef APP-NVUE */
  336. display: block;
  337. /* #endif */
  338. margin-right: 10px;
  339. width: 30px;
  340. height: 30px;
  341. }
  342. .xialakuang{
  343. display: flex;
  344. flex-direction: row;
  345. align-items: center;
  346. justify-content:space-between;
  347. padding-left: 10rpx;
  348. width: 140rpx;
  349. height: 60rpx;
  350. margin-right: 20rpx;
  351. border-radius: 10rpx;
  352. border: 2rpx solid darkgray;
  353. }
  354. .inputctV{
  355. width: 90%;
  356. height: 120rpx;
  357. margin-left: 5%;
  358. margin-top: 30rpx;
  359. }
  360. .ctinrow{
  361. display: flex;
  362. flex-direction: row;
  363. align-items: center;
  364. justify-content: left;
  365. }
  366. .inputV{
  367. margin-top: 8rpx;
  368. width: 100%;
  369. height: 60rpx;
  370. font-size: 28rpx;
  371. border-radius: 8rpx;
  372. border: 2rpx solid darkgray;
  373. }
  374. .inputphone{
  375. margin-top: 8rpx;
  376. width: 100%;
  377. height: 60rpx;
  378. font-size: 28rpx;
  379. border-radius: 8rpx;
  380. border: 2rpx solid darkgray;
  381. }
  382. .savebt{
  383. text-align: center;
  384. font-size: 36rpx;
  385. width: 80%;
  386. height: 80rpx;
  387. line-height: 80rpx;
  388. color: white;
  389. background-color: #40AE36;
  390. border-radius: 10rpx;
  391. }
  392. .delbt{
  393. margin-top: 50rpx;
  394. text-align: center;
  395. font-size: 36rpx;
  396. width: 80%;
  397. height: 80rpx;
  398. line-height: 80rpx;
  399. color: white;
  400. background-color: darkgray;
  401. border-radius: 10rpx;
  402. }
  403. .imagV{
  404. width: 640rpx;
  405. height: 640rpx;
  406. background-color: antiquewhite;
  407. }
  408. .picker-view {
  409. width: 750rpx;
  410. height: 300rpx;
  411. margin-top: 10rpx;
  412. }
  413. .item {
  414. line-height: 100rpx;
  415. text-align: center;
  416. }
  417. </style>