AccountForm.vue 8.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. <template><page-meta :root-font-size="fontSize+'px'"></page-meta>
  2. <seller-base :show="false">
  3. <view class="div container">
  4. <view class="div common-header-wrap">
  5. <view :style="'height:'+navHeight+'px'"></view>
  6. <view class="common-header-holder"></view>
  7. <view class="common-header-fixed">
  8. <title-header />
  9. <uni-nav-bar :title="getTitle" class="common-header" left-icon="back" @clickLeft="goBack()">
  10. <view class="div common-btn btn" slot="right" @click="onDelete" v-if="!isAddMode">删除</view>
  11. </uni-nav-bar>
  12. </view>
  13. </view>
  14. <view class="div main-content">
  15. <view class="div" v-if="isAddMode">
  16. <flex-line class="field-line" :show-border="true"><text class="span field-name">商城账号</text><view class="div field-line-right" slot="right"><input class="field-input" v-model="seller.member_name" /></view></flex-line>
  17. <flex-line class="field-line" :show-border="true"><text class="span field-name">密码</text><view class="div field-line-right" slot="right"><input class="field-input" type="password" v-model="seller.password" /></view></flex-line>
  18. </view>
  19. <view class="div" v-else>
  20. <flex-line :show-border="true"><text class="span line-name">卖家账号</text><text class="span" slot="right">{{seller.seller_name}}</text></flex-line>
  21. </view>
  22. <view class="div select" @click="showPopup('popupVisible')" >
  23. <flex-line :is-link="true" :show-border="true"><text class="span line-name">账号组</text><text class="span" slot="right">{{seller.sellergroup_name?seller.sellergroup_name: '请选择'}}</text></flex-line>
  24. </view>
  25. <view class="div pt-10 pb-10"><view class="div common-btn ds-button-large mt-10" @click="submit">提交</view></view>
  26. </view>
  27. <uni-popup background-color="#fff" ref="popupVisible" type="bottom" class="mint-popup">
  28. <view>
  29. <view class="div toolbar">
  30. <text class="button toolbar-item cancel-item" @click="hidePopup('popupVisible')">取消</text>
  31. <view class="div picker-header">选择帐号组</view>
  32. <text class="button toolbar-item confirm-item" @click="handleConfirm">确定</text>
  33. </view>
  34. </view>
  35. <picker-view class="popup-content" indicator-style="height:80rpx" @change="onBusinessChange" :value="sgPicker">
  36. <picker-view-column v-for="(item,index) in sellerGroupList" :key="index">
  37. <view class="popup-item-wrapper" v-for="(v,i) in item.values" :key="i"><text class="popup-item">{{v.sellergroup_name}}</text></view>
  38. </picker-view-column>
  39. </picker-view>
  40. </uni-popup>
  41. </view>
  42. <uni-popup background-color="#fff" ref="confirm" type="dialog">
  43. <uni-popup-dialog :mode="dialog.mode" :title="dialog.title" :content="dialog.content" :placeholder="dialog.content" @confirm="confirmDialog" @close="closeDialog"></uni-popup-dialog>
  44. </uni-popup>
  45. </seller-base>
  46. </template>
  47. <script>
  48. import {getFontSize} from '@/util/common'
  49. import TitleHeader from '../../TitleHeader'
  50. import SellerBase from '../SellerBase'
  51. import { getSellerAccountInfo, getSellerAccountGroupList, delSellerAccount, editSellerAccount, addSellerAccount } from '../../../api/sellerAccount'
  52. import flexLine from '../../flexLine'
  53. export default {
  54. name: 'AccountForm',
  55. data(){
  56. return {
  57. navHeight: 0,
  58. sgPicker:[0],
  59. dialog:{},
  60. sellergroup_list: [], // 账号组
  61. seller: {
  62. 'seller_id': 0,
  63. 'member_name': '', // 商城用户名
  64. 'seller_name': '', // 卖家用户名
  65. 'password': '',
  66. 'sellergroup_id': 0,
  67. 'sellergroup_name': '',
  68. 'action':''
  69. }
  70. }
  71. },
  72. components:{TitleHeader,SellerBase,flexLine,},
  73. onLoad: function (option) {
  74. this.action = option.action
  75. // 获取店铺的账户组
  76. getSellerAccountGroupList().then(res => {
  77. this.sellergroup_list = res.result.sellergroup_list
  78. }).catch(function (error) {
  79. uni.showToast({icon:'none',title: error.message})
  80. })
  81. if (!this.isAddMode) {
  82. this.seller.seller_id = option.seller_id
  83. getSellerAccountInfo(this.seller.seller_id).then(res => {
  84. this.seller = res.result.seller_info
  85. }).catch(function (error) {
  86. uni.showToast({icon:'none',title: error.message})
  87. })
  88. }
  89. },
  90. computed:{
  91. fontSize(){
  92. return getFontSize()
  93. },
  94. isAddMode () {
  95. let mode = this.action
  96. if (mode === 'add') {
  97. return true
  98. } else {
  99. return false
  100. }
  101. },
  102. getTitle () {
  103. if (this.isAddMode) {
  104. return '新增账户'
  105. } else {
  106. return '修改账户'
  107. }
  108. },
  109. sellerGroupList () {
  110. let sellerGroupList = [
  111. {
  112. flex: 1,
  113. values: this.sellergroup_list,
  114. className: 'slot1',
  115. textAlign: 'center'
  116. }
  117. ]
  118. return sellerGroupList
  119. }
  120. },
  121. mounted(){
  122. // #ifdef MP-WEIXIN
  123. this.navHeight = uni.getMenuButtonBoundingClientRect().height
  124. // #endif
  125. },
  126. methods:{
  127. onBusinessChange (e) {
  128. this.sgPicker=e.detail.value
  129. },
  130. closeDialog(){
  131. },
  132. confirmDialog(value){
  133. delSellerAccount(this.seller.seller_id).then(
  134. (response) => {
  135. uni.navigateTo({url:'/pages/seller/account/AccountList'})
  136. }, (error) => {
  137. uni.showToast({icon:'none',title: error.message})
  138. })
  139. },
  140. showPopup(id){
  141. this.$refs[id].open()
  142. },
  143. hidePopup(id){
  144. this.$refs[id].close()
  145. },
  146. goBack(){uni.navigateBack({delta:1})},
  147. // 确认事件
  148. handleConfirm () {
  149. this.seller.sellergroup_id = this.sellerGroupList[0]['values'][this.sgPicker[0]]['sellergroup_id']
  150. this.seller.sellergroup_name = this.sellerGroupList[0]['values'][this.sgPicker[0]]['sellergroup_name']
  151. this.hidePopup('popupVisible')
  152. },
  153. onDelete () {
  154. this.dialog={content:'确定要取消该账号吗?'}
  155. this.$refs.confirm.open()
  156. },
  157. submit () {
  158. if (this.isAddMode) {
  159. uni.showLoading({ title: '加载中' })
  160. addSellerAccount(this.seller).then(
  161. (response) => {
  162. uni.hideLoading()
  163. uni.showToast({icon:'none',title: response.message})
  164. uni.navigateTo({url:'/pages/seller/account/AccountList'})
  165. }, (error) => {
  166. uni.hideLoading()
  167. uni.showToast({icon:'none',title: error.message})
  168. })
  169. } else {
  170. uni.showLoading({ title: '加载中' })
  171. editSellerAccount(this.seller).then(
  172. (response) => {
  173. uni.hideLoading()
  174. uni.showToast({icon:'none',title: response.message})
  175. // uni.navigateTo({url:'/pages/seller/account/AccountList'})
  176. }, (error) => {
  177. uni.hideLoading()
  178. uni.showToast({icon:'none',title: error.message})
  179. })
  180. }
  181. }
  182. }
  183. }
  184. </script>
  185. <style scoped lang="scss">
  186. .common-header{
  187. .btn{background: #000;color: #fff;box-shadow: 0px 2px 4px #d2d2d2;}
  188. }
  189. .main-content{background: #fff;padding:0 $pageSpace}
  190. .popup-content {
  191. padding: 0 40rpx;
  192. height: 300rpx;
  193. }
  194. .toolbar {
  195. height: 2rem;
  196. display: flex;
  197. flex-direction: row;
  198. justify-content: space-between;
  199. align-items: center;
  200. background-color: #f0f2f5;
  201. .toolbar-item {
  202. font-size:$fontSize;
  203. border: none;
  204. border-radius: 0;
  205. background-color: #f0f2f5;
  206. }
  207. .cancel-item {
  208. margin-left: 0.5rem;
  209. color: #4e545d;
  210. }
  211. .confirm-item {
  212. margin-right: 0.5rem;
  213. color: red;
  214. }
  215. .picker-header {
  216. color: #4e545d;
  217. line-height: 2rem;
  218. font-size:$h2;
  219. }
  220. }
  221. .popup-item-wrapper{
  222. display: flex;
  223. justify-content: center;
  224. align-items: center;
  225. }
  226. .popup-item {
  227. font-size: 30rpx;
  228. line-height:80rpx;
  229. text-align: center;
  230. overflow: hidden;
  231. text-overflow: ellipsis;
  232. white-space: nowrap;
  233. }
  234. </style>