uni-popup-address.vue 7.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330
  1. <template>
  2. <view class="uni-popup-dialog">
  3. <view class="uni-dialog-title">
  4. <!--<text class="uni-dialog-title-text" :class="['uni-popup__'+dialogType]">{{title}}</text>-->
  5. <!--<text>保健品一件</text>-->
  6. <view class="uni-popup-image">
  7. <image :src="small_pic" style="width: 50px;height: 50px;"></image>
  8. </view>
  9. <view class="uni-popup-info">
  10. <text>¥{{amount}}</text>
  11. <text>{{goods_name}}</text>
  12. </view>
  13. <view class="iconfont-im icon-close fix-icon-title" @tap="close"></view>
  14. </view>
  15. <view class="uni-dialog-content">
  16. <view class="uni-content-ceil" style="margin-right: 110rpx;">
  17. <view class="uni-content-ceil-title" >
  18. <text>收货地址:</text>
  19. </view>
  20. <pick-regions :defaultRegion="userAddress.regionCode" @getRegion="handleGetRegion" ref="regions">
  21. <view style="font-size: 16px;font-weight: 400" class="uni-content-ceil-input uni-input-input" >{{userAddress.regionStr ? userAddress.regionStr : '请点击选择地址'}} </view>
  22. </pick-regions>
  23. </view>
  24. <view class="uni-content-ceil">
  25. <view class="uni-content-ceil-title">
  26. <text>详细地址:</text>
  27. </view>
  28. <input type="text" :value="userAddress.address" @input="address" placeholder="请输入详细地址" class="uni-content-ceil-input" />
  29. </view>
  30. <view class="uni-content-ceil">
  31. <view class="uni-content-ceil-title">
  32. <text>收货人:</text>
  33. </view>
  34. <input type="text" :value="userAddress.username" @input="username" placeholder="请输入收货人" class="uni-content-ceil-input" />
  35. </view>
  36. <view class="uni-content-ceil">
  37. <view class="uni-content-ceil-title">
  38. <text>手机号:</text>
  39. </view>
  40. <input type="number" :value="userAddress.mobile" maxlength="11" @input="mobile" placeholder="请输入手机号" class="uni-content-ceil-input" />
  41. </view>
  42. </view>
  43. <view class="uni-dialog-button-group">
  44. <button type="primary" @tap="onOk" style="width: 80%;border-radius: 30px;">支付</button>
  45. </view>
  46. </view>
  47. </template>
  48. <script>
  49. /**
  50. * PopUp 弹出层-对话框样式
  51. * @description 弹出层-对话框样式
  52. * @tutorial https://ext.dcloud.net.cn/plugin?id=329
  53. * @property {String} value input 模式下的默认值
  54. * @property {String} placeholder input 模式下输入提示
  55. * @property {String} type = [success|warning|info|error] 主题样式
  56. * @value success 成功
  57. * @value warning 提示
  58. * @value info 消息
  59. * @value error 错误
  60. * @property {String} mode = [base|input] 模式、
  61. * @value base 基础对话框
  62. * @value input 可输入对话框
  63. * @property {String} content 对话框内容
  64. * @property {Boolean} beforeClose 是否拦截取消事件
  65. * @event {Function} confirm 点击确认按钮触发
  66. * @event {Function} close 点击取消按钮触发
  67. */
  68. import pickRegions from '@/components/pick-regions/pick-regions.vue';
  69. export default {
  70. name: "uniPopupAddress",
  71. props: {
  72. value: {
  73. type: [String, Number],
  74. default: ''
  75. },
  76. maxlength:{
  77. type: Number,
  78. default: 10
  79. },
  80. placeholder: {
  81. type: [String, Number],
  82. default: '请输入内容'
  83. },
  84. /**
  85. * 对话框主题 success/warning/info/error 默认 success
  86. */
  87. type: {
  88. type: String,
  89. default: 'error'
  90. },
  91. /**
  92. * 对话框模式 base/input
  93. */
  94. mode: {
  95. type: String,
  96. default: 'base'
  97. },
  98. /**
  99. * 对话框标题
  100. */
  101. title: {
  102. type: String,
  103. default: '提示'
  104. },
  105. /**
  106. * 对话框内容
  107. */
  108. content: {
  109. type: String,
  110. default: ''
  111. },
  112. /**
  113. * 拦截取消事件 ,如果拦截取消事件,必须监听close事件,执行 done()
  114. */
  115. beforeClose: {
  116. type: Boolean,
  117. default: false
  118. },
  119. small_pic: {
  120. type: String,
  121. default: ''
  122. },
  123. goods_name: {
  124. type: String,
  125. default: ''
  126. },
  127. amount: {
  128. type: String,
  129. default: ''
  130. },
  131. userAddress:{
  132. type:Object,
  133. default:()=>{
  134. return {
  135. regionStr: '',
  136. username: '',
  137. mobile: '',
  138. address: '',
  139. regionCode:'440113'
  140. }
  141. }
  142. }
  143. },
  144. data() {
  145. return {
  146. dialogType: 'error',
  147. focus: false,
  148. val: ""
  149. }
  150. },
  151. components:{
  152. pickRegions
  153. },
  154. inject: ['popup'],
  155. watch: {
  156. type(val) {
  157. this.dialogType = val
  158. },
  159. mode(val) {
  160. if (val === 'input') {
  161. this.dialogType = 'info'
  162. }
  163. },
  164. value(val) {
  165. this.val = val
  166. }
  167. },
  168. created() {
  169. // 对话框遮罩不可点击
  170. this.popup.mkclick = false
  171. if (this.mode === 'input') {
  172. this.dialogType = 'info'
  173. this.val = this.value
  174. } else {
  175. this.dialogType = this.type
  176. }
  177. },
  178. mounted() {
  179. this.focus = true
  180. },
  181. methods: {
  182. username(e){
  183. console.log(e.detail.value)
  184. return this.userAddress.username = e.detail.value;
  185. },
  186. mobile(e){
  187. return this.userAddress.mobile = e.detail.value;
  188. },
  189. address(e){
  190. return this.userAddress.address = e.detail.value;
  191. },
  192. handleGetRegion(region){
  193. this.userAddress.regionStr =region[0]['name']+region[1]['name']+region[2]['name'];
  194. this.userAddress.regionCode = region[2]['code'] ? region[2]['code'] : region[1]['code'];
  195. },
  196. onOk() {
  197. //判断手机号
  198. if(this.userAddress.regionStr == '')return uni.showToast({title:"请选择地址",icon:'none'});
  199. if(this.userAddress.address == '')return uni.showToast({title:"请输入详细地址",icon:'none'});
  200. if(this.userAddress.mobile == '')return uni.showToast({title:"请输入手机号",icon:'none'});
  201. if(this.userAddress.username == '')return uni.showToast({title:"请输入收货人",icon:'none'});
  202. this.$emit('confirm',this.userAddress)
  203. },
  204. /**
  205. * 点击取消按钮
  206. */
  207. close() {
  208. if (this.beforeClose) {
  209. this.$emit('close', () => {
  210. this.popup.close()
  211. })
  212. return
  213. }
  214. this.popup.close()
  215. }
  216. }
  217. }
  218. </script>
  219. <style lang="scss" scoped>
  220. .uni-popup-dialog {
  221. background-color: #fff;
  222. }
  223. .uni-popup-dialog button{
  224. line-height: unset;
  225. }
  226. .fix-icon-title{
  227. position: relative;
  228. }
  229. .uni-dialog-title {
  230. /* #ifndef APP-NVUE */
  231. display: flex;
  232. /* #endif */
  233. flex-direction: row;
  234. justify-content: flex-start;
  235. padding: 20px 20px;
  236. }
  237. .icon-close:before{
  238. content: "\e620";
  239. position: absolute;
  240. display:block;
  241. width: 0;
  242. height: 0;
  243. left: 360rpx;
  244. top: -20rpx;
  245. }
  246. .uni-popup-image{
  247. display: flex;
  248. justify-content: center;
  249. align-items: center;
  250. }
  251. .uni-popup-info {
  252. display: flex;
  253. flex-direction: column;
  254. margin-left: 20px;
  255. }
  256. .uni-dialog-content {
  257. /* #ifndef APP-NVUE */
  258. display: flex;
  259. /* #endif */
  260. flex-direction: column;
  261. justify-content: center;
  262. align-items: center;
  263. }
  264. .uni-dialog-content-text {
  265. font-size: 14px;
  266. color: #6e6e6e;
  267. }
  268. .uni-dialog-button-group {
  269. /* #ifndef APP-NVUE */
  270. display: flex;
  271. /* #endif */
  272. flex-direction: row;
  273. padding: 10px 0;
  274. }
  275. .uni-dialog-input {
  276. flex: 1;
  277. font-size: 14px;
  278. overflow: visible !important;
  279. line-height :1.9rem !important;
  280. height:1.9rem !important;
  281. border-radius: 10px;
  282. padding-left:2px;
  283. background-color: #eeeeee;
  284. }
  285. .uni-popup__success {
  286. color: $uni-color-success;
  287. }
  288. .uni-popup__warn {
  289. color: $uni-color-warning;
  290. }
  291. .uni-popup__error {
  292. color: $uni-color-error;
  293. }
  294. .uni-popup__info {
  295. color: #909399;
  296. }
  297. .uni-content-ceil{
  298. display: flex;
  299. flex-direction: row;
  300. justify-content: center;
  301. width: 100%;
  302. padding: 8px 0;
  303. }
  304. .uni-content-ceil-title{
  305. font-size: 16px;
  306. margin-right: 10upx;
  307. }
  308. .uni-content-ceil-input{
  309. border-bottom: 1upx solid #A9A9A9;
  310. padding: 0 50rpx;
  311. justify-content:space-around;
  312. }
  313. </style>